dj4uk
Nov 6th, 2006, 07:03 AM
Hi
I'm using the following C# code to hash a password before it is stored in a database.
public static string Encrypt(string cleanString)
{
Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString);
Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
return BitConverter.ToString(hashedBytes);
}
When someone logs in I hash the password entered and compare against the stored hashed password.
Now this seems to work in most cases but every so often the hashed passwords don't match!
Just wondering if there is a salt or anything similar that might be setup somewhere e.g. machine.config.
This is all on a shared server so it is possible the host is changing something somewhere that I don't know about.
Help!
DJ
I'm using the following C# code to hash a password before it is stored in a database.
public static string Encrypt(string cleanString)
{
Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString);
Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
return BitConverter.ToString(hashedBytes);
}
When someone logs in I hash the password entered and compare against the stored hashed password.
Now this seems to work in most cases but every so often the hashed passwords don't match!
Just wondering if there is a salt or anything similar that might be setup somewhere e.g. machine.config.
This is all on a shared server so it is possible the host is changing something somewhere that I don't know about.
Help!
DJ