PDA

View Full Version : SHA1 Hash


ganymede
11-25-2005, 01:51 PM
Not sure why but when i compute the SHA1 hash in .NET and compare what is found in the password file i get problems. Pasted code below

current = hash in user file
strHex = computed hash


UnicodeEncoding UE = new UnicodeEncoding();


byte[] HashValue, MessageBytes = UE.GetBytes(password.Trim());
System.Security.Cryptography.SHA1Managed SHhash = new System.Security.Cryptography.SHA1Managed();
string strHex = "";

HashValue = SHhash.ComputeHash(MessageBytes);


foreach(byte b in HashValue) {

strHex += String.Format("{0:x2}", b);
}


if(current == strHex)
return true;
else
return false;

Can anyone help?

current = cc714d9311474c5167ed05c9a8f7a2462533e156
strHex = c4bd41cfd6d8762f3e8c9d5209ff610f1e2bb49e

ganymede
11-26-2005, 02:24 AM
FIXED :for those of you who care want to know :

//UnicodeEncoding UE = new UnicodeEncoding();
System.Text.UTF8Encoding UE = new UTF8Encoding();