java - How to get original password from BCryptPasswordEncoder -
i'm using spring security application. when user register first time, passwords encrypted bcryptpasswordencoder . bcryptpasswordencoder passwordencoder = new bcryptpasswordencoder(); string hashedpassword = passwordencoder.encode(password); now, in case of password changing, users enter current password , need check if current password same against encrypted password saved in database. i know not possible generate 2 same encrypted hash same string bcryptpasswordencoder . way compare passwords if same original password saved in database , compare current entered password. so, there way compare passwords or original password database saved hashed password? you need check raw password against encoded password in db. example, bcryptpasswordencoder bcryptpasswordencoder = new bcryptpasswordencoder(); string p = bcryptpasswordencoder.encode("somecoolpassword"); system.out.println(bcryptpasswordencoder.matches("somecoolpassword", p));