首页 > 解决方案 > 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...

标签: javasqlspring

解决方案


"passwordbdd" 和 "loginForm.get("password").toString()" 以相同的方式“散列”...

您从表单中获得的密码不应该被散列。这是 BCryptPasswordEncoder 数学方法的工作方式:

    if(encoder.matches(userInputPassword, databaseHashedPassword)) {
        // intput password matches! 
    }

推荐阅读