Created
June 17, 2012 03:20
-
-
Save newbyca/2943281 to your computer and use it in GitHub Desktop.
a password class i'm using in my nodejs project. i decided this abstraction was appropriate given a desire to create password hashs asyncly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bcrypt = require 'bcrypt' | |
class password | |
text = null | |
salt = null | |
hash = null | |
@saltAndHash = (text, done) -> | |
bcrypt.genSalt (err, salt) -> | |
if err | |
return done err | |
password.hash text, salt, (err, pwd) -> | |
return done err, pwd | |
@hash = (text, salt, done) -> | |
pwd = new password | |
pwd.text = text | |
pwd.salt = salt | |
bcrypt.hash text, salt, (err, hash) -> | |
if err | |
return done err | |
pwd.hash = hash | |
return done null, pwd | |
module.exports = password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment