Created
February 17, 2016 05:00
-
-
Save BarronKane/ff813214bbdbfb715ab5 to your computer and use it in GitHub Desktop.
Revisions
-
Lance created this gist
Feb 17, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ 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); }); }); });