Skip to content

Instantly share code, notes, and snippets.

@aspnetde
Created January 8, 2015 10:38
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 aspnetde/5b4d433584c015bdb0b7 to your computer and use it in GitHub Desktop.
Save aspnetde/5b4d433584c015bdb0b7 to your computer and use it in GitHub Desktop.
Node.js bcrypt password creator
var bcrypt = require("bcrypt");
var clearPassword = "test";
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash(clearPassword, salt, function(err, hash) {
bcrypt.compare(clearPassword, hash, function(err, res) {
if (res === true && !err) {
console.log("Hashed password: " + hash);
} else {
console.warn("ERROR: " + err)
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment