Thread: SHA1 Hash
View Single Post
Old 11-25-2005, 01:51 PM  
ganymede
Member
 
Join Date: Dec 2004
Posts: 46
Default SHA1 Hash

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 is offline   Reply With Quote