这样在SQL Server中存储的哈希密码应该是什么样的?
alt text http://img28.imageshack.us/img28/2545/88871034.gif
这是我用来哈希密码的函数(我在一些教程中找到了它)
public string EncryptPassword(string password)
{
//we use codepage 1252 because that is what sql server uses
byte[] pwdBytes = Encoding.GetEncoding(1252).GetBytes(password);
byte[] hashBytes = System.Security.Cryptography.MD5.Create().ComputeHash(pwdBytes);
return Encoding.GetEncoding(1252).GetString(hashBytes);
}
修改 我尝试使用sha-1,现在字符串看起来像他们想象的那样:
public string EncryptPassword(string password)
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(password, "sha1");
}
// example output: 39A43BDB7827112409EFED3473F804E9E01DB4A8
上图中的结果看起来像破碎的字符串,但是这个sha-1看起来很正常....
这足够安全吗?