java - how to compare my password "bcrypt" with my database?
问题描述
For the authentication of my application, I have a control of my password "hashed" of the form and that of my database which is also "hashé", but that does not work?
Here is my condition :
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
if ((pseudobdd.equals(loginForm.get("pseudo").toString()))
&&
(encoder.matches(passwordbdd, loginForm.get("password").toString()))) {
"passwordbdd" and "loginForm.get("password").toString()" are "hashed" in the same way...
解决方案
"passwordbdd" 和 "loginForm.get("password").toString()" 以相同的方式“散列”...
您从表单中获得的密码不应该被散列。这是 BCryptPasswordEncoder 数学方法的工作方式:
if(encoder.matches(userInputPassword, databaseHashedPassword)) {
// intput password matches!
}
推荐阅读
- html - 输入属性 type="number" 在 IE11 中不起作用。我怎样才能解决这个问题?
- android - 通过从 Flutter 中的 firebase 实时数据库中获取布尔值来更新按钮的状态
- jquery - jquery-migrate.js:43 Uncaught TypeError: jQuery.migrateWarnings.push not a function 问题
- javascript - 将光标悬停在图像上后 - 箭头必须出现在左侧和右侧
- javascript - 自定义图像库上的图像闪烁
- javascript - 如何在我的对象标签的内屏幕上获得与输入网站控制台命令相同的效果?
- javascript - Quasar:当我单击其中一个菜单时,drawerClick 不起作用
- sql - 查询每个品种每分钟数据的差异
- assembly - 仅装配数字输入
- xml - 无法为安装 WiX 设置自定义位置。安装后,它只安装在 C\programfiles86 中。它只有 bundle.wxs 没有 product.wxs