php - 正确加盐和使用 PHPass

标签 php security phpass

长期以来,我一直在使用 PHPass 来散列我的密码。我承认仍然有一些我不完全理解(或忽略)的东西来正确地散列密码,所以今天我正在审查我能找到的所有关于它的信息。

查看 PHPass 文档,我已经介入了:

Besides the actual hashing, phpass transparently generates random salts when a new password or passphrase is hashed, and it encodes the hash type, the salt, and the password stretching iteration count into the "hash encoding string" that it returns. When phpass authenticates a password or passphrase against a stored hash, it similarly transparently extracts and uses the hash type identifier, the salt, and the iteration count out of the "hash encoding string". Thus, you do not need to bother with salting and stretching on your own - phpass takes care of these for you.

我把困扰我的句子加粗了。
我一直认为盐应该有点 secret ,因为它不应该被攻击者知道。因此,如果理解正确,PHPass 会将使用的盐存储在同一哈希中,以便在比较密码和检查是否有效时使用它。
我的问题是

  1. 这安全吗?如果散列被泄露,攻击者就会得到用于对密码进行散列的盐...这里有一些我想念的东西。
  2. 我真的可以自由地为密码加盐而烦恼吗?我真的可以依赖 PHPass 吗?

最佳答案

一点背景
盐并不意味着是 secret 的,相反,盐通过确保散列结果对每个使用的实例都是唯一的来“起作用”。这是通过为每个计算的哈希选择不同的随机盐值来完成的。

盐的意图在已知时不妥协;攻击者仍然需要分别攻击每个散列。因此,您可以简单地将盐与密码一起存储。

那么,PHPass 安全吗?
是的! PHPass(根据最佳实践)为您生成强随机盐。这是一个经过良好审查且质量上乘的图书馆。

感兴趣的链接:
How to securely hash passwords?
How to store salt?
Password Hashing add salt + pepper or is salt enough?
Salt Generation and open source software

关于php - 正确加盐和使用 PHPass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12140178/

相关文章:

php - 带有字符的子页面/

security - 是否可以限制开发人员可以创建的策略?

javascript - 如何安全地转义 bigquery Node 插入的用户输入?可以在 bigquery.insert Node 库上使用参数化查询吗?

PHP SoapClient 和一个复杂的 header

php - 将 FB.Logout 插入其他脚本中的注销按钮/Fb.logout 不起作用

php empty() 无法正常工作

phpass 安全密码存储的最佳解决方案?

java - 从内存中检索字节码以防止黑客攻击

php - 在 PHPass 中使用现有的 MD5 散列是否存在任何安全隐患?

mysql - 在 mysql 中复制 wordpress 密码哈希