Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
failing early when decryption fails
azivnera8e45019e43d
diff --git a/services/data_encryption.js b/services/data_encryption.jsindex 31ebf90443..4de137972a 100644--- a/services/data_encryption.js+++ b/services/data_encryption.js@@ -1,6 +1,7 @@"use strict";const crypto = require('crypto');+const log = require('./log');function arraysIdentical(a, b) {let i = a.length;@@ -72,7 +73,15 @@ function decrypt(key, iv, cipherText) {function decryptString(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) {