Skip to content

Instantly share code, notes, and snippets.

@heroic
Created April 24, 2011 06:06
Show Gist options
  • Save heroic/939366 to your computer and use it in GitHub Desktop.
Save heroic/939366 to your computer and use it in GitHub Desktop.
bcrypt
var bcrypt = require('bcrypt')
// function encrypt_password(password, salt, cb) {
// var encrypted = password + salt
// for (var i=10;i>0;i--) {
// encrypted = sha512(encrypted)
// }
// bcrypt.encrypt(encrypted, salt, function(err, hash) {
// cb(hash)
// })
// }
// encrypt_password('amit','salt', function(hash){
// console.log(hash)
// })
bcrypt.encrypt('amitkjh//', 'sal$tedsalt', function(err, hash) {
console.log(hash)
})
// var bcrypt = require('bcrypt'); bcrypt.gen_salt(10, function(err, salt) { bcrypt.encrypt("B4c0//", salt, function(err, hash) { bcrypt.compare("B4c0//", hash, function(err, res) { console.log(res)
// }); bcrypt.compare("not_bacon", hash, function(err, res) { console.log(res) }); }); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment