从其他用户字段生成盐

发布于 2024-12-20 17:18:38 字数 132 浏览 1 评论 0原文

现在,我在数据库(用户表)中有一个“盐”列和一个“密码”列,两者都是 varchar(64) 并采用 sha-256 哈希值作为值。

您认为消除盐列并在密码验证期间使用用户的电子邮件地址生成盐是个好主意吗?这将节省数据库中的一些空间。

Right now I have a "salt" column and a "password" column in the database (the user table), both varchar(64) and take sha-256 hashes as values.

Do you think it's a good idea to eliminate the salt column and use the user's e-mail address to generate a salt during password validation? This would save some space in the database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

葵雨 2024-12-27 17:18:38

我认为存储随机盐不是问题,而不是从用户的其他列中派生它们。

但是,如果您决定使用一个或多个其他列作为盐,则需要 100% 确保所选值永远不会改变。在您的示例中,如果用户更改了电子邮件地址,您就失去了验证其密码的任何方法。

I don't think it's a problem to store the a random salt, instead of deriving them from other columns of the user.

However, if you decide to use one or more other columns for the salt, you need to be 100% sure that the value chosen never changes. In your example, if the user changes email address, you have lost any way to validate his password.

九局 2024-12-27 17:18:38

请参阅此答案了解为什么您应该使用为每个密码创建提供随机盐。

See this answer for why you should use a random salt for every password creation.

挽清梦 2024-12-27 17:18:38

盐永远不应该改变。电子邮件地址即可。您对删除盐柱的想法相当于 DBA 的过早优化,并且会带来灾难性的结果。

A salt should never, ever change. An Email address can. Your thinking of the removal of the salt column is the DBA equivalent of premature optimization, with the added consequence of disastrous results.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文