Jasypt Users Forum

problem with registration and login

View: New views
1 Messages — Rating Filter:   Alert me  

problem with registration and login

by pranav_cache :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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...