Hi,
Please make sure you are using same encryptor in both cases creating the encrypted password and matching the user password with the DB password.
Leo.
pranav_cache wrote:
Hi,
i am working on an struts application. I need to register a user and encrypt his Password in my DataBase. While the next time the user login, what am doing is to get his password from the html form and check it with the encrypted password from database.
But the passwordEncryptor.checkPassword is throwing me false.
Here is what am trying to do-:
BasicPasswordEncryptor passwordEncryptor = Utility.passwordEncryptor; // using same instance both for encryption in regBean setPwd and checking in Login action class as below
if (passwordEncryptor.checkPassword( loginform.getPwd(), resultset.getString("password"))) {
System.out.println("correct Login!");
}
while this works in simple Java program. The below gives me correct Login.
String userPassword = "qwerty";
String inputPassword = "qwerty";
BasicPasswordEncryptor passwordEncryptor = Utility.passwordEncryptor;;
String encryptedPassword = passwordEncryptor .encryptPassword(userPassword);
if (passwordEncryptor.checkPassword(inputPassword, encryptedPassword)) {
System.out.println("correct Login!);
}
Please inform...