java - 在 Spring 安全性中,matches 函数如何返回 false?
问题描述
我不明白为什么我的 BCryptPasswordEncoder 匹配函数在此处返回 false,从而导致身份验证失败。我正在使用hibernate和Spring5,当我对密码进行编码时,匹配后它返回false。
String randomPassword="admin";
logger.info("Random Password " + randomPassword);
String encodedPassword=bCrypt.encode("randomPassword");
logger.info("Encoded Random Password " + encodedPassword);
Boolean b = bCrypt.matches(randomPassword, encodedPassword);
System.out.println("This should be true( " + b + " )");
解决方案
您编码错误的值。
线
String encodedPassword=bCrypt.encode("randomPassword");
应该
String encodedPassword=bCrypt.encode(randomPassword);
.
推荐阅读
- html - 放置一个
- jquery - 输入时的 jQuery 可排序更新输出
- c# - 在 ListView 列中创建 CheckBox
- docker - 无法从 docker 容器内部发送邮件
- sql - 使用“INSERT OVERWRITE”使用 databricks delta 更改数据捕获
- java - 如何基于 feign.Response 抛出异常?
- url - 通过 JxBrowser 发布请求不会交出数据
- ios - 是否可以在 UICollectionView 下有一个 UITableView?
- .net - 无论使用 TLS 1.1 的 .net 代码如何,都使用 TLS 1.2
- java - 如何按嵌套地图值对外部地图进行排序