java - BCrypt 更新库和交互 - 它会破坏我的登录吗?

标签 java spring-security bcrypt

我有一个旧的遗留应用程序,使用 Spring Security (3.1.0) 来实现 BCrypt。 哈希值具有某种格式,例如

$2a$10$Cas1.FrwwQ3...WqS1i31gHrk12J9YK

对于编码器的实现:

PasswordEncoder BCRYPT = new BCryptPasswordEncoder(BCRYP_ITERATIONS);

用于创建哈希(存储在数据库中)和匹配。

我的问题是:

  1. 如果我只是将 BCRYP_ITERATIONS 从当前的 10 更改为 18,这会破坏我的登录吗?
    从我对 BCrypt 的理解来看,它不会——至于匹配,它只会使用存储在哈希本身内部的迭代值 ($2a$10$)。 为了创建要存储在数据库中的新哈希值,将使用新值。

  2. 如果我将库更新为使用 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/

相关文章:

java - 关于关键字,Java 中的 "new"

java - 是否有 jackson 注释来抑制不必要的 JSON 包装?

Spring Security 禁用登录页面/重定向

spring - 如何在我的Spring 4.0 RestFul Web服务上实现Spring Security?

javascript - 无法让 Bcrypt.js 加密用户模型密码

Laravel 5 : using bcrypt on same string gives different values

java - 从枚举序数转换为枚举类型

spring-security 不会使 http session 失效

node.js - 此 Node 实例的 N-API 版本为 1。此模块支持 N-API 版本 3。此 Node 实例无法运行此模块

java - 为什么Netty不执行我的定时任务?