mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
use native concat instead of own reimplementation
This commit is contained in:
parent
b192336113
commit
b64ef6311c
@ -185,10 +185,10 @@ const encryption = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function encrypt(aes, str) {
|
function encrypt(aes, str) {
|
||||||
const payload = aesjs.utils.utf8.toBytes(str);
|
const payload = Array.from(aesjs.utils.utf8.toBytes(str));
|
||||||
const digest = sha256Array(payload).slice(0, 4);
|
const digest = sha256Array(payload).slice(0, 4);
|
||||||
|
|
||||||
const digestWithPayload = concat(digest, payload);
|
const digestWithPayload = digest.concat(payload);
|
||||||
|
|
||||||
const encryptedBytes = aes.encrypt(digestWithPayload);
|
const encryptedBytes = aes.encrypt(digestWithPayload);
|
||||||
|
|
||||||
@ -220,20 +220,6 @@ const encryption = (function() {
|
|||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
function concat(a, b) {
|
|
||||||
const result = [];
|
|
||||||
|
|
||||||
for (let key in a) {
|
|
||||||
result.push(a[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let key in b) {
|
|
||||||
result.push(b[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function sha256Array(content) {
|
function sha256Array(content) {
|
||||||
const hash = sha256.create();
|
const hash = sha256.create();
|
||||||
hash.update(content);
|
hash.update(content);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user