I’ve been trying to integrate MD5 hashes to my WP7 app but I’ve noticed that the Silverlight MD5 implementation http://archive.msdn.microsoft.com/SilverlightMD5 does not return the same hash if I compare with PHP’s MD5 result. If I hash once, the hash values are equal, but if I hash more than once, the final hash result is different. Has anyone else noticed this or any idea why this might happen, possible fix, etc?
PHP Code
$pwd = "pwd";
for ($i=0; $i < 2 ; $i++)
{
$pwd = md5($pwd);
}
print $pwd;
WP7 Code
String hashpwd = "pwd";
for (int i = 0; i < 2; i++)
{
String hash = hashpwd;
hashpwd = MD5Core.GetHashString(hash);
}
MessageBox.Show(hashpwd);
Assuming that the MD5 calculation is correct, you should have a look at the output of the first run and if they are exactly the same. For example, if PHP uses lower case characters
a–f, but WP7 uses uppercase charactersA–F, the second MD5 sum will be different.