bCrypt的javadoc中给出了如何加密密码的代码:
String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
要检查明文密码是否与先前哈希过的密码匹配,请使用checkpw方法:
if (BCrypt.checkpw(candidate_password, stored_hash))
System.out.println("It matches");
else
System.out.println("It does not match");
这些代码片段让我觉得随机生成的 salt 被丢弃了。这是真的吗,还是这只是一个误导性的代码片段?