Skip to content

Instantly share code, notes, and snippets.

@andreguerrerosilvera
Created January 29, 2020 22:31
Show Gist options
  • Select an option

  • Save andreguerrerosilvera/e3f612b823455832e0933175f398ceef to your computer and use it in GitHub Desktop.

Select an option

Save andreguerrerosilvera/e3f612b823455832e0933175f398ceef to your computer and use it in GitHub Desktop.
Generate a hash to password when user create an account
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