ACP*_*ACP 17 c# passwords hash
海家伙,
我开始知道存储密码的哈希值是从数据库中存储密码的首选方法中安全的...
如何使用c#对密码值进行加密和散列?
如何比较存储在DB中的值和用户给出的值?
简单哈希:
public string GetSHA256Hash(string s)
{
if (string.IsNullOrEmpty(s))
{
throw new ArgumentException("An empty string value cannot be hashed.");
}
Byte[] data = System.Text.Encoding.UTF8.GetBytes(s);
Byte[] hash = new SHA256CryptoServiceProvider().ComputeHash(data);
return Convert.ToBase64String(hash);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12310 次 |
| 最近记录: |