Files
Notes/src/services/my_scrypt.js
T
2018-09-05 15:14:20 +02:00

30 lines
680 B
JavaScript

"use strict";
const optionService = require('./options');
const scrypt = require('@mlink/scrypt');
async function getVerificationHash(password) {
const salt = await optionService.getOption('passwordVerificationSalt');
return getScryptHash(password, salt);
}
async function getPasswordDerivedKey(password) {
const salt = await optionService.getOption('passwordDerivedKeySalt');
return getScryptHash(password, salt);
}
async function getScryptHash(password, salt) {
const hashed = scrypt.hashSync(password,
{N: 14, r:8, p:1},
32,
salt);
return hashed;
}
module.exports = {
getVerificationHash,
getPasswordDerivedKey
};