mirror of
https://github.com/zadam/trilium.git
synced 2025-03-12 15:56:26 +08:00
failing early when decryption fails
This commit is contained in:
parent
7f7028873c
commit
a8e45019e4
1 changed files with 10 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const log = require('./log');
|
||||||
|
|
||||||
function arraysIdentical(a, b) {
|
function arraysIdentical(a, b) {
|
||||||
let i = a.length;
|
let i = a.length;
|
||||||
|
@ -72,7 +73,15 @@ function decrypt(key, iv, cipherText) {
|
||||||
function decryptString(dataKey, iv, cipherText) {
|
function decryptString(dataKey, iv, cipherText) {
|
||||||
const buffer = decrypt(dataKey, iv, cipherText);
|
const buffer = decrypt(dataKey, iv, cipherText);
|
||||||
|
|
||||||
return buffer.toString('utf-8');
|
const str = buffer.toString('utf-8');
|
||||||
|
|
||||||
|
if (str === 'false') {
|
||||||
|
log.error("Could not decrypt string. Buffer: " + buffer);
|
||||||
|
|
||||||
|
throw new Error("Could not decrypt string.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function noteTitleIv(iv) {
|
function noteTitleIv(iv) {
|
||||||
|
|
Loading…
Reference in a new issue