Created
January 29, 2020 22:31
-
-
Save andreguerrerosilvera/e3f612b823455832e0933175f398ceef to your computer and use it in GitHub Desktop.
Generate a hash to password when user create an account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const generatePasswordHash = async (password) => { | |
| try { | |
| const salt = await bcrypt.genSalt(saltRounds); | |
| const passwordHashed = await bcrypt.hash(password, salt); | |
| return passwordHashed; | |
| } catch (err) { | |
| throw new Error(`The salt or the hash couldn't be generated`) | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment