Created
February 17, 2016 05:00
-
-
Save BarronKane/ff813214bbdbfb715ab5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
app.post('/', function (req, res) { | |
if (!req.body.user || !req.body.pass) { | |
res.send('Username and password both required'); | |
return; | |
} | |
crypto.randomBytes(128, function (err, salt) { | |
if (err) { throw err; } | |
salt = new Buffer(salt).toString('hex'); | |
crypto.pbkdf2(req.body.pass, salt, 7000, 256, | |
function (err, hash) { | |
if (err) { throw err; } | |
userStore[req.body.user] = {salt : salt, | |
hash : (new Buffer(hash).toString('hex')) }; | |
res.send('Thanks for registering ' + req.body.user); | |
console.log(userStore); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment