I am using AES256 encryption but it can be decrypt with secure key. And i hash the encrypted password and store in my DB. But the plain-text "password" encrypt different each time. And hash by BCrypt different each time.How can i store or check password when user submit his/her password?
AES256Encryption d = new AES256Encryption();
String password = "password";
System.out.println("password : " + password);
String encPsw = d.encrypt(password);
System.out.println("Encrypted string:" + encPsw);
String hash = BCrypt.hashpw(encPsw, BCrypt.gensalt());
System.out.println("hashed string : " + hash);
if(BCrypt.checkpw(password,hash )){
System.err.println("password matched!!");
}else{
System.err.println("password not matched!!");
}
These codes always prints "password not matched!!". How can i compare user's password and hashed password from database?