简体   繁体   中英

Is there a way to decrypt Salt Hashing in JavaScript?

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM