Skip to content

Instantly share code, notes, and snippets.

@daveteu
Created May 18, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daveteu/8426390078c5ee1d123e2d940154e33f to your computer and use it in GitHub Desktop.
Save daveteu/8426390078c5ee1d123e2d940154e33f to your computer and use it in GitHub Desktop.
Bcrypt with NodeJS
const bcrypt = require('bcrypt');
let passwordHash;
bcrypt.hash('passwordString', 10, function(err, hash) {
passwordHash = hash;
});
bcrypt.compare('differentpasswordString', passwordHash, function(err, res) {
if(res) {
console.log(res) //returns true
} else {
console.log(res) //returns false
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment