mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
use native node crypto for sha256
This commit is contained in:
parent
dd5a142fdd
commit
2533b8e121
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const aesjs = require('./aes');
|
const aesjs = require('./aes');
|
||||||
const sha256 = require('./sha256');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
function getProtectedSessionId(req) {
|
function getProtectedSessionId(req) {
|
||||||
return req.headers['x-protected-session-id'];
|
return req.headers['x-protected-session-id'];
|
||||||
@ -12,15 +12,6 @@ function getDataAes(dataKey) {
|
|||||||
return new aesjs.ModeOfOperation.ctr(dataKey, new aesjs.Counter(5));
|
return new aesjs.ModeOfOperation.ctr(dataKey, new aesjs.Counter(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
function arraysIdentical(a, b) {
|
|
||||||
let i = a.length;
|
|
||||||
if (i !== b.length) return false;
|
|
||||||
while (i--) {
|
|
||||||
if (a[i] !== b[i]) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function decrypt(dataKey, encryptedBase64) {
|
function decrypt(dataKey, encryptedBase64) {
|
||||||
if (!dataKey) {
|
if (!dataKey) {
|
||||||
return "[protected]";
|
return "[protected]";
|
||||||
@ -64,9 +55,16 @@ function encrypt(dataKey, plainText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sha256Array(content) {
|
function sha256Array(content) {
|
||||||
const hash = sha256.create();
|
return crypto.createHash('sha256').update(content).digest();
|
||||||
hash.update(content);
|
}
|
||||||
return hash.array();
|
|
||||||
|
function arraysIdentical(a, b) {
|
||||||
|
let i = a.length;
|
||||||
|
if (i !== b.length) return false;
|
||||||
|
while (i--) {
|
||||||
|
if (a[i] !== b[i]) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user