java - Spring 的 BCrypt 实现

标签 java spring spring-mvc cryptography bcrypt

我正在尝试使用 Spring's BCrypt implementation 。我注意到 checkpw() 方法有两个参数:明文密码和哈希值。在不包含盐的情况下,该方法如何能够验证这一点?

最佳答案

它可以验证,这并不神奇 - BCrypt 编码的哈希值包含盐。您可以将盐存储在变量中以进行检查:

String salt = BCrypt.gensalt();
String pw_hash = BCrypt.hashpw(plain_password, salt);

System.out.println(salt);
System.out.println(pw_hash);

关于java - Spring 的 BCrypt 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26049791/

相关文章:

java - 将 map 传递给 JSP

java - Android中如何滚动布局的所有内容?

java - Spring 3.2 Security - 使用非唯一用户名和附加信息登录

javax.persistence.Entity 未导入?

Spring Controller ,为什么返回的 View 被忽略了?

spring-mvc - @Autowired 字段在一个 SpringMVC Controller 中为空,而其他 Controller 工作

java - 我可以删除我的 Spring Framework webapp 响应数据中不必要的换行符/空格吗?

java - Web 方法 :can we remove an element from the documentList while looping through it

java - Spring Batch - 是否可以在 FlatFileReader 中有一个动态列?

java - Spring Web 服务不会读取 JSON