我通過使用產生從我的密碼鹽和哈希值,[Sql-Server]用於密碼salt和hash值的數據類型以及長度是多少?
string salt = CreateSalt(TxtPassword.Text.Length);
string hash = CreatePasswordHash(TxtPassword.Text, salt);
private static string CreateSalt(int size)
{
//Generate a cryptographic random number.
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] buff = new byte[size];
rng.GetBytes(buff);
// Return a Base64 string representation of the random number.
return Convert.ToBase64String(buff);
}
private static string CreatePasswordHash(string pwd, string salt)
{
string saltAndPwd = String.Concat(pwd, salt);
string hashedPwd =
FormsAuthentication.HashPasswordForStoringInConfigFile(
saltAndPwd, "sha1");
return hashedPwd;
}
你會建議在SQL Server中存儲這些值的數據類型是什麼?任何建議...
鹽:9GsPWpFD
哈希:E778AF0DC5F2953A00B35B35D80F6262CDBB8567
+很好的問題。 – 2010-05-19 06:03:50