mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
29 lines
633 B
JavaScript
29 lines
633 B
JavaScript
"use strict";
|
|
|
|
const optionService = require('./options');
|
|
const crypto = require('crypto');
|
|
|
|
function getVerificationHash(password) {
|
|
const salt = optionService.getOption('passwordVerificationSalt');
|
|
|
|
return getScryptHash(password, salt);
|
|
}
|
|
|
|
function getPasswordDerivedKey(password) {
|
|
const salt = optionService.getOption('passwordDerivedKeySalt');
|
|
|
|
return getScryptHash(password, salt);
|
|
}
|
|
|
|
function getScryptHash(password, salt) {
|
|
const hashed = crypto.scryptSync(password, salt, 32,
|
|
{N: 16384, r:8, p:1});
|
|
|
|
return hashed;
|
|
}
|
|
|
|
module.exports = {
|
|
getVerificationHash,
|
|
getPasswordDerivedKey
|
|
};
|