hashed/salted 个密码的寿命

Lifespan of hashed/salted passwords

虽然我了解 过程 对密码进行加盐和哈希处理背后的神学,但我不太了解其中的方法。据我所知,this question and it's pertinent answers, as well as this MSDN article 中列出的方法都经过一些步骤来创建不同长度的盐,以在给定密码的散列过程中使用。

但是,稍后检查密码怎么样?据我所知,重新创建哈希将导致生成 一个全新的盐 ,最终导致尝试登录时验证失败。

我是否遗漏了盐或盐配方的保存位置?还是我不太了解流程?

你应该:

  1. 为每个要散列的密码创建一个新盐
  2. 哈希密码
  3. 将散列和盐都保存为​​纯文本

当您想要对您的用户进行身份验证时,您只需使用您之前保存在数据库中的盐再次计算哈希值,然后比较您的哈希值。

这是an excellent article that explains the process in details. It also provides a complete C# implementation