gpt4 book ai didi

C#哈希密码创建盐问题

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

如果我使用类似这样的方法创建盐:

public class User
{
private const int Hash_Salt_Length = 8;
private byte[] saltBytes = new byte[Hash_Salt_Length];


public User()
{
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetNonZeroBytes(saltBytes);
}
....

}

对于每个 session (重新启动应用程序),saltBytes 字节数组将不同。我如何检查密码以允许用户登录我们的应用程序?

最佳答案

您需要将盐与密码哈希一起存储在数据库中。

请注意,您不应调用 GetNonZeroBytes,因为它提供的随机性较低。

关于C#哈希密码创建盐问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3025489/

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