mirror of https://github.com/TriliumNext/Notes
server-ts: services/encryption/*.js -> ts
parent
dc359b2a74
commit
c20d2273e6
@ -1,28 +1,28 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const optionService = require('../options.js');
|
import optionService = require('../options.js');
|
||||||
const crypto = require('crypto');
|
import crypto = require('crypto');
|
||||||
|
|
||||||
function getVerificationHash(password) {
|
function getVerificationHash(password: crypto.BinaryLike) {
|
||||||
const salt = optionService.getOption('passwordVerificationSalt');
|
const salt = optionService.getOption('passwordVerificationSalt');
|
||||||
|
|
||||||
return getScryptHash(password, salt);
|
return getScryptHash(password, salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPasswordDerivedKey(password) {
|
function getPasswordDerivedKey(password: crypto.BinaryLike) {
|
||||||
const salt = optionService.getOption('passwordDerivedKeySalt');
|
const salt = optionService.getOption('passwordDerivedKeySalt');
|
||||||
|
|
||||||
return getScryptHash(password, salt);
|
return getScryptHash(password, salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getScryptHash(password, salt) {
|
function getScryptHash(password: crypto.BinaryLike, salt: crypto.BinaryLike) {
|
||||||
const hashed = crypto.scryptSync(password, salt, 32,
|
const hashed = crypto.scryptSync(password, salt, 32,
|
||||||
{N: 16384, r:8, p:1});
|
{N: 16384, r:8, p:1});
|
||||||
|
|
||||||
return hashed;
|
return hashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export = {
|
||||||
getVerificationHash,
|
getVerificationHash,
|
||||||
getPasswordDerivedKey
|
getPasswordDerivedKey
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue