一次性盐和服务器密码比较
我读过,对用户进行身份验证的更安全方法之一是在对密码进行哈希处理时使用一次性盐。我不明白的是:
如果客户端每次会话都生成一个新的盐,那么每次会话生成的盐+密码哈希值是否都会不同?如果是这样,服务器如何将发送的密码与其存储的密码进行比较?有没有一种方法可以让服务器比较不同的哈希值并且仍然能够辨别出使用了相同的密码?
(免责声明:我并不是想重新发明轮子/编写登录协议(我知道,我知道:使用 SSL/TLS)。我只是对登录协议的高级功能感到好奇)
I've read that one of the more secure ways to authenticate a user is to use one time salts when hashing the password. What I don't get is:
If the client generates a new salt every session, won't the resulting salt+password hash be different every session? If so, how will the server be able to compare the sent password with it's stored password? Is there a way for servers to compare different hashes and still be able to discern that the same password was used?
(Disclaimer: I'm not trying to reinvent the wheel/write a login protocol (I know, I know: use SSL/TLS). I'm just curious as to the high level functioning of login protocols)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需要生成盐一次,并且可以在每次更改密码时生成。
客户不需要将盐存储在任何地方,甚至不需要意识到这一点。盐将与哈希值一起由服务器存储。
建议您将哈希值和盐存储在两个不同的数据库中。
You only need to generate the salt only once and may every time the password been changed.
The client needs not to store the salt anywhere or even been aware of that. The salt will be stored by the server - along with the hash.
Its recommended that you store the hash and the salt in two different databases..
仅当用户最初设置密码时才生成新的盐。然后您将盐与密码哈希一起保存。
you only generate a new salt when the user sets the password initially. Then you save the salt along with the password hash.