backend ported to node.js (work in progress)

This commit is contained in:
azivner
2017-10-14 23:31:44 -04:00
parent 14acacf2e9
commit cc3a621324
26 changed files with 2118 additions and 0 deletions

28
node/my_scrypt.js Normal file
View File

@@ -0,0 +1,28 @@
const sql = require('./sql');
const scrypt = require('scrypt');
async function getVerificationHash(password) {
const salt = await sql.getOption('password_verification_salt');
return getScryptHash(password, salt);
}
async function getPasswordDerivedKey(password) {
const salt = await sql.getOption('password_derived_key_salt');
return getScryptHash(password, salt);
}
async function getScryptHash(password, salt) {
const hashed = scrypt.hashSync(password,
{N: 16384, r:8, p:1},
32,
salt);
return hashed;
}
module.exports = {
getVerificationHash,
getPasswordDerivedKey
};