I'm trying to get a C# Sha1 hash in PHP. The C# code was handed to me, it appears to use ASCIIEncoding which from what I read is what PHP uses. Not sure what is wrong. Any tips are appreciated.
C# code:
byte[] data = Encoding.ASCII.GetBytes(text);
byte[] HashValue;
SHA1Managed SHhash = new SHA1Managed();
hashValue = SHhash.ComputeHash(data);
foreach (byte b in hashValue)
{
sha1string += String.Format("{0:x2}", b);
}
return sha1string;
PHP Code:
return sha1(text);
The output:
C# : 5f10f7410406cdab11f3c44fe8c634718eb68e98
PHP : bba18b9b35c440c25b8dcf2efb973d86ee1442e2