I am using different calls to the same crypto provider that return different hashes. I need to have the same hashes in order for my program to work. Below is the code I am executing. I am open to any suggesions.
I solved the problem by not using the cryptography block at all. Below is the code I used. The hash value is now the same on multiple hash calls for the same string.
string verifiableMesage = "It was the best of times, it was the worst of times. ";
SHA1Managed sha = new SHA1Managed() ;
byte[] hashValue =
sha. ComputeHash(System. Text.ASCIIEncoding. ASCII. GetBytes(verifiableMesage) ) ;
Member
1 Points
11 Posts
Different hash values returned for same string
Dec 02, 2010 05:50 PM|ebrinkman|LINK
I am using different calls to the same crypto provider that return different hashes. I need to have the same hashes in order for my program to work. Below is the code I am executing. I am open to any suggesions.
mystring = EncryptData(User.Identity.Name.Substring(4));
mystring2 = EncryptData(User.Identity.Name.Substring(4));
areEqual = mystring.SequenceEqual(mystring2);
byte[] mystring;byte[] mystring2;bool areEqual;
private byte[] EncryptData(string myInput)
{
byte[] valueToHash = Encoding.UTF8.GetBytes(myInput);
return generatedHash = Cryptographer.CreateHash(hashProvider, valueToHash);
}
Member
1 Points
11 Posts
Re: Different hash values returned for same string
Dec 03, 2010 09:46 AM|ebrinkman|LINK
I solved the problem by not using the cryptography block at all. Below is the code I used. The hash value is now the same on multiple hash calls for the same string.
string verifiableMesage = "It was the best of times, it was the worst of times. ";
SHA1Managed sha = new SHA1Managed() ;
byte[] hashValue =
sha. ComputeHash(System. Text.ASCIIEncoding. ASCII. GetBytes(verifiableMesage) ) ;