gpt4 book ai didi

c# - FIPS 验证算法将密码存储在数据库中?

转载 作者:太空宇宙 更新时间:2023-11-03 20:31:07 24 4
gpt4 key购买 nike

我正在寻找一种经过 FIPS 验证的哈希算法来将密码存储在数据库中。我确实使用了以下代码,但仍然出现错误

This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.

SHA1CryptoServiceProvider Testsha1 = new SHA1CryptoServiceProvider();
byte[] hashedBytes;
UTF8Encoding encoder = new UTF8Encoding();
hashed = Testsha1.ComputeHash(encoder.GetBytes(strPassword));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashed.Length; i++)
{
sbuilder.Append(hashed[i].ToString("x2"));
}
string Password = sb.ToString();

最佳答案

不应使用普通 SHA-1 来存储密码。 PBKDF2 是一个不错的选择。在 .net 中,您可以将它与 Rfc2898DeriveBytes 类一起使用。参见 https://security.stackexchange.com/questions/2131/reference-implementation-of-c-password-hashing-and-verification/2136#2136

您可能需要将底层哈希函数更改为 SHA-256。据我所知,SHA-1 并未获得 NIST 批准。

关于c# - FIPS 验证算法将密码存储在数据库中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7505270/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com