mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 17:26:38 +01:00
encryption code separated into its own file
This commit is contained in:
@@ -12,4 +12,22 @@ function error(str) {
|
||||
error.show();
|
||||
error.html(str);
|
||||
error.fadeOut(10000);
|
||||
}
|
||||
|
||||
function uint8ToBase64(u8Arr) {
|
||||
const CHUNK_SIZE = 0x8000; //arbitrary number
|
||||
const length = u8Arr.length;
|
||||
let index = 0;
|
||||
let result = '';
|
||||
let slice;
|
||||
while (index < length) {
|
||||
slice = u8Arr.subarray(index, Math.min(index + CHUNK_SIZE, length));
|
||||
result += String.fromCharCode.apply(null, slice);
|
||||
index += CHUNK_SIZE;
|
||||
}
|
||||
return btoa(result);
|
||||
}
|
||||
|
||||
function base64ToUint8Array(base64encoded) {
|
||||
return new Uint8Array(atob(base64encoded).split("").map(function(c) { return c.charCodeAt(0); }));
|
||||
}
|
||||
Reference in New Issue
Block a user