I am trying to use c# md5 and php md5 to calculate the same result but they give different results. The c# code must be the same as the php code.
public string ToMD5(string orderId, string statusCode, string secretKey)
{
string key = orderId + "+" + statusCode;
key = Base64Encode(key);
MD5 m = System.Security.Cryptography.MD5.Create();
byte[] h = m.ComputeHash(Encoding.Default.GetBytes(key + secretKey));
string r = "";
foreach (byte b in h)
{
r += b.ToString("X2");
}
return r;
}
And here is the php code:
$key = $orderid."+".$status;
$prec = base64_encode($key);
$prec = $prec.$SecretKey;
$prec = md5($prec);
echo $prec;
c# returns : CEC71705E5A25CCD21609B72053539FC
php returns : f1542715b25b302553119fda1e8567bb
Thanks for any help.