Let's say I have this Backend Code which Hashes the password of the user
const salt = await bcrypt.genSalt(10);
const hashedPass = await bcrypt.hash(req.body.password, salt);
And for the auth, I just use the Bcrypt Compare function
const validated = await bcrypt.compare(req.body.password, user.password);
It works. But let's say I want to know the Password as well. Is there a bcrypt
function for that? Because as far as I know, the only thing it can do is compare the Passwords.
CodePudding user response:
The whole point of password hashing is making an irreversible action so that anyone else including you cannot reverse the process and get the password. So answer is you can't know. Once it has been hashed there is no going back.
CodePudding user response:
Hashing (either it is MD5 salt hashing, SHA256/SHA512 or salt hashing) is a one way function,you cannot decrypt it, instead you can use RSA encryption with diffie hellman key exchange technique.
Bcrypt library is for Hashing passwords, if you want to retrieve back passwords, you can't do with it.
Instead use RSA with Deffie hellman key exchange technique to securely share keys.