关于加盐密码的问题

发布于 2024-10-12 01:31:27 字数 66 浏览 4 评论 0原文

好的。举例来说,我将密码的盐设置为“hello”。难道有人不能只看源代码并发现盐吗?如果是这样,我该如何隐藏它?谢谢。

Okay. Say for example that i set the salt for a password to "hello." Can't someone just look at the source code and discover the salt? If so, how would I hide it? Thanks.

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

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

发布评论

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

评论(5

为人所爱 2024-10-19 01:31:27

通常以纯文本形式与密码哈希一起存储。它们存在的主要原因是使预计算的彩虹表的使用变得更加困难,并且更难以使用对数据库中的所有密码执行字典攻击

您还应该为每个密码使用不同随机生成的盐,而不是为整个应用程序使用单一盐。这意味着每个密码必须单独破解。

Salts are are usually stored in plain text alongside the password hash. The main reason they are there is to make it more difficult to use precomputed rainbow tables and more difficult to perform a dictionary attack on all the passwords in the database.

You should also use a different randomly generated salt for each password, rather than a single salt for your entire application. This means that each password must be cracked separately.

夕嗳→ 2024-10-19 01:31:27

首先:安全很难。不要尝试自己做,因为你会把事情搞砸的。使用完善的库来处理用户身份验证。

其次,您似乎误解了盐的用途。盐只是为了防止密码哈希值被轻易逆转 - 每个用户都应该有一个唯一的盐,但最好将盐存储在与哈希密码相同的位置。

First of all: Security is HARD. Don't try and do it yourself, because you will screw it up. Use a well-established library to handle user authentication.

Secondly, you seem to misunderstand the purpose of a salt. The salt is just there to prevent easy reversing of password hashes - there should be a unique salt for each user, but it's fine to store the salt in the same place as the hashed password.

谜泪 2024-10-19 01:31:27

盐在动态时是最好的(比如成员的加入日期)。即使攻击者知道您计算散列的方式,他们也必须暴力破解每个加盐和散列的密码 - 这需要花费大量时间,因为(通常)奖励很少。

话虽这么说,如果攻击者在服务器端查看您的代码,那么您已经遇到了一个更大的问题。

Salts are best when they are dynamic (say the member's join date). Even if the attacker knows the way you compute the hash, they have to brute force each salted and hashed password -- which takes a lot of time, for (in general) little reward.

That being said, if the attacker is looking at your code server-side, you already have a much larger problem.

生死何惧 2024-10-19 01:31:27

1)不要对多个帐户使用相同的盐。如果您无法显示源代码并相信您的密码仍然安全,那么您就错了。

2) PKCS #5 v2.1,第 4 节

1) Don't use the same salt for multiple accounts. If you can't show your source-code and trust that your passwords are still secure, you've done it wrong.

2) PKCS #5 v2.1, section 4

生生不灭 2024-10-19 01:31:27

希望您的“源代码”运行在网络服务器上,而不是在任何人都可以看到的客户端(javascript)上运行。

Hopefully, your "source code" is running on a web server, and not on the client side (javascript) where anybody can see it.

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