Hey,
I have a couple different bits of code but the short story is I insert some passwords into a MySQL database using SHA1 and also compute SHA1 hashes into .NET and they are not matching. I think this is a problem with my encoding code in .NET.
SQL Code:
INSERT INTO user_credentials (Password) VALUES (SHA1('password'));
password hashes to 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
.NET Code:
public static string GetPasswordHash(string password)
{
// problem here with encoding?
byte[] byteArray = Encoding.ASCII.GetBytes(password);
SHA1 sha = new SHA1CryptoServiceProvider();
byte[] hashedPasswordBytes = sha.ComputeHash(byteArray);
return Encoding.ASCII.GetString(hashedPasswordBytes);
}
password hashes to [?a??????%l?3~???
Thanks for any help!