使用另一种盐验证密码+盐

发布于 2024-12-17 19:34:58 字数 181 浏览 3 评论 0原文

我将用户的凭据与编码密码存储在数据库中:sha1(pw + salt) 和 salt。 当我尝试从客户端应用程序登录用户时,我仅使用不同的盐值执行相同的操作,因此我发送 sha1(pw + another_salt) 和 another_salt 进行授权。

问题是,应该对接收到的编码密码进行哪些进一步修改,以便能够检查存储的值。

I'm storing the user's credentials in a database with the encoded password: sha1(pw + salt) and the salt.
When I'm trying to login the user from a client app I do the same thing only with a different salt value, so I send the sha1(pw + another_salt) and another_salt for authorization.

The question is that what further modification should be done to the received encoded password to be able to check against the stored value.

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

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

发布评论

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

评论(1

浮生未歇 2024-12-24 19:34:58

如果您从客户端发送某些内容,那么它是散列密码还是字符串并不重要。如果它是由客户端生成的内容(即您在客户端而不是服务器上生成盐) - 攻击者也可以只发送您的字符串。因此,如果它不是安全连接,那么您添加额外的工作是没有帮助的。

为了允许使用另一种盐检查服务器上的密码,您需要以明文形式存储原始密码。

这就是在数据库中存储哈希值而不是密码的全部目的是不允许仅从哈希值猜测它们。如果您另外对它们加盐,那么您需要使用相同的盐(它是公开的,因为它以明文形式存储在数据库中,但它现在是原始密码的一部分)。你问的是这样的:

如何登录用户(其密码是“安全密码”+“硬”=> sha1(“安全密码硬”))发送某些内容+“软”(然后使用 sha1(某些内容+“软”)进行测试) 反而。

如果您确实需要此应用程序工作,只需从客户端应用程序以明文形式发送用户密码,但通过安全连接。

If you send something from client it doesn't matter if it's hashed password or just string. And if it's content generated by client (i.e. you generate salt on client, not on server) - attacker could as well just send your string. So if it's not secured connection, then you add additional work which doesn't help.

To allow checking passwords on server with another salt, you need to store original password in clear text.

That's the whole point of storing hashes instead of passwords in database is to not allow guessing them from hash only. And if you salt them additionally, then you need to use the same salt (it's public, as it's stored in database in clear text, but it's now part of original password). What you ask is something like this:

Haw to login on user (whose password is "secure password" + "hard" => sha1("secure passwordhard")) sending something + "soft" (and then test with sha1(something + "soft")) instead.

If you really need this app to work, just send user's password in cleartext from client app, but over secured connection.

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