C
Casper Hornstrup
I need to use MD5 to generate a hash of a string. It needs to be
compatible with the MD5 implementation in PHP.
public string ComputeMD5(string plain)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] bMD5Hash = Encoding.ASCII.GetBytes(plain);
return Encoding.ASCII.GetString(md5.ComputeHash(bMD5Hash));
//return Convert.ToBase64String(md5.ComputeHash(bMD5Hash));
}
With PHP I get:
md5('test1test1test1test1test1test1') = '0b2fc97f2a37500552d805c4727295a8'
In .NET I get:
ComputeMD5('test1test1test1test1test1test1') = '/I*7PRXDrr('
ComputeMD5('test1test1test1test1test1test1') = 'Cy/Jfyo3UAVS2AXEcnKVqA=='
(base64)
Am I doing it wrong or are the PHP and .NET implementations not compatible?
Thanks in advance,
Casper Hornstrup
compatible with the MD5 implementation in PHP.
public string ComputeMD5(string plain)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] bMD5Hash = Encoding.ASCII.GetBytes(plain);
return Encoding.ASCII.GetString(md5.ComputeHash(bMD5Hash));
//return Convert.ToBase64String(md5.ComputeHash(bMD5Hash));
}
With PHP I get:
md5('test1test1test1test1test1test1') = '0b2fc97f2a37500552d805c4727295a8'
In .NET I get:
ComputeMD5('test1test1test1test1test1test1') = '/I*7PRXDrr('
ComputeMD5('test1test1test1test1test1test1') = 'Cy/Jfyo3UAVS2AXEcnKVqA=='
(base64)
Am I doing it wrong or are the PHP and .NET implementations not compatible?
Thanks in advance,
Casper Hornstrup