Browse Source

migrated to a new version of scrypt

master
mort 8 years ago
parent
commit
437b595992
3 changed files with 4 additions and 4 deletions
  1. 1
    1
      package.json
  2. 2
    2
      web/api/account_create.node.js
  3. 1
    1
      web/api/account_login.node.js

+ 1
- 1
package.json View File

"jshint": "^2.8.0", "jshint": "^2.8.0",
"mlogger": "^1.1.0", "mlogger": "^1.1.0",
"pg": "^4.4.0", "pg": "^4.4.0",
"scrypt": "^4.0.7",
"scrypt": "^5.1.0",
"uglify-js": "^2.4.24", "uglify-js": "^2.4.24",
"uglifycss": "0.0.15", "uglifycss": "0.0.15",
"wrench": "^1.5.8" "wrench": "^1.5.8"

+ 2
- 2
web/api/account_create.node.js View File

if (!/^[a-zA-Z0-9_\-]+$/.test(data.username)) if (!/^[a-zA-Z0-9_\-]+$/.test(data.username))
return ctx.fail("Username contains illegal characters."); return ctx.fail("Username contains illegal characters.");


var params = scrypt.params(ctx.conf.scrypt.maxtime);
scrypt.hash(new Buffer(data.password), params, function(err, hash) {
var params = scrypt.paramsSync(ctx.conf.scrypt.maxtime);
scrypt.kdf(new Buffer(data.password), params, function(err, hash) {
if (err) if (err)
return ctx.fail(err); return ctx.fail(err);



+ 1
- 1
web/api/account_login.node.js View File



ctx.login(user.username, user.id); ctx.login(user.username, user.id);


scrypt.verify(
scrypt.verifyKdf(
new Buffer(user.pass_hash, "hex"), new Buffer(user.pass_hash, "hex"),
new Buffer(ctx.postData.data.password), new Buffer(ctx.postData.data.password),
function(err, success) { function(err, success) {

Loading…
Cancel
Save