Skip to content

Instantly share code, notes, and snippets.

@hassaananjum
Created March 7, 2018 06:58
Show Gist options
  • Save hassaananjum/6e4620bd54786367f261d3ad2c3d5165 to your computer and use it in GitHub Desktop.
Save hassaananjum/6e4620bd54786367f261d3ad2c3d5165 to your computer and use it in GitHub Desktop.
//basic usage bcrypt hashing
var bcrypt = require('bcrypt');
function createHash(password){
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash(password, salt, function (err, hash) {
if (err) {
console.log(err);
return err;
} else {
console.log(hash);
bcrypt.compare('redbuffer', hash).then(function(res){
console.log(res);
}).catch(function(err){
console.log(err);
})
return hash;
}
});
});
}
createHash('12345');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment