most likely you have a bug where you are not sending the same string and secret. just add log to see.
Facing issue with hashing in c#
Sahu, Jagannath
1
Reputation point
Hi,
I am facing an issue with the hashing.
I am using the below code for hashing.
i have to hash certain number and inserting in to a database table.
i am using two applications . in both the application i am using the same number which has to be hashed and the same secret key.
ideally it should save same value in database, but both the hashed values are different, its very strange.
Any help is appreciated.
public static byte[] GetHashValue(string text, string secret)
{
string hash = text + secret;
byte[] tmpSource;
byte[] tmpHash;
//Create a byte array from source data
tmpSource = Encoding.ASCII.GetBytes(hash);
//Compute hash based on source data
using (var md5 = MD5.Create())
{
tmpHash = md5.ComputeHash(tmpSource);
}
return tmpHash;
}