为什么jbcrypt在比较时不需要盐

时间:2016-12-25 08:16:04

标签: java jbcrypt

我目前正在寻找一个可以在网络应用中存储盐渍,哈希密码的图书馆。我遇到mindrot's jbcrypt并认为这可能是正确的选择(另见https://security.stackexchange.com/questions/21184/safe-to-use-jbcrypt-and-recommend-it-to-my-organization)。但是,有一点让我对代码感到困惑。通常,哈希和盐渍密码为done by calling

String hashed = BCrypt.hashpw(password, BCrypt.gensalt(12));

使用生成的盐。要稍后检查密码,here您可以看到(以及在mindrot页面上)

if (BCrypt.checkpw(candidate, hashed))
使用纯文本候选项调用

函数。另外,在jbcrypt的编码中说

public static boolean checkpw(String plaintext, String hashed)

现在我的问题是如何比较纯文本密码和盐渍+哈希字符串而不在比较时使用盐(因为它没有传递给checkpw函数,显然)?

0 个答案:

没有答案