我有一个旧的遗留应用程序,使用 Spring Security (3.1.0) 来实现 BCrypt。 哈希值具有某种格式,例如
$2a$10$Cas1.FrwwQ3...WqS1i31gHrk12J9YK
对于编码器的实现:
PasswordEncoder BCRYPT = new BCryptPasswordEncoder(BCRYP_ITERATIONS);
用于创建哈希(存储在数据库中)和匹配。
我的问题是:
如果我只是将
BCRYP_ITERATIONS
从当前的 10 更改为 18,这会破坏我的登录吗?
从我对 BCrypt 的理解来看,它不会——至于匹配,它只会使用存储在哈希本身内部的迭代值 ($2a$10$
)。 为了创建要存储在数据库中的新哈希值,将使用新值。如果我将库更新为使用 BCryprt 新版本 (
$2b$
) 的最新实现 – 这会破坏我的登录吗?
因为它以某种方式改变了方法,我会说是的——这是真的吗?
最佳答案
升级 Spring Security 不会中断您的登录,因为 Spring Security 5.2 的最新快照仍然支持 $2a
,请参阅 BCryptPasswordEncoder
:
Implementation of PasswordEncoder that uses the BCrypt strong hashing function. Clients can optionally supply a "version" ($2a, $2b, $2y) and a "strength" (a.k.a. log rounds in BCrypt) and a SecureRandom instance. The larger the strength parameter the more work will have to be done (exponentially) to hash the passwords. The default value is 10.
18 个日志轮次也不应该破坏您的登录,因为 Spring Security 5.2 的最新快照仍然支持 4 到 31 个日志轮次,请参阅 BCryptPasswordEncoder
:
strength - the log rounds to use, between 4 and 31
关于java - BCrypt 更新库和交互 - 它会破坏我的登录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54120983/