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