mirror of
https://github.com/zadam/trilium.git
synced 2024-11-17 21:21:40 +08:00
28 lines
No EOL
662 B
JavaScript
28 lines
No EOL
662 B
JavaScript
"use strict";
|
|
|
|
const optionService = require('./options');
|
|
const crypto = require('crypto');
|
|
|
|
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 = crypto.scryptSync(password, salt, 32,
|
|
{N: 16384, r:8, p:1});
|
|
|
|
return hashed;
|
|
}
|
|
|
|
module.exports = {
|
|
getVerificationHash,
|
|
getPasswordDerivedKey
|
|
}; |