Skip to content

Commit

Permalink
Updated EasyEncryptionEverywhere to fix issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
mdnahas committed Jun 5, 2024
1 parent 542cfe6 commit 9ec7543
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions EasyEncryptionEverywhere.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,26 @@
}, aesKey, fileUint8Array.buffer)];
case 3:
encryptedFile = _a.sent();
base64EncodedSalt = btoa(String.fromCharCode.apply(null, new Uint8Array(salt)));
base64EncodedIv = btoa(String.fromCharCode.apply(null, new Uint8Array(iv)));
base64EncodedEncryptedFile = btoa(String.fromCharCode.apply(null, new Uint8Array(encryptedFile)));
base64EncodedSalt = btoa(Uint8ArrayToString(new Uint8Array(salt)));
base64EncodedIv = btoa(Uint8ArrayToString(new Uint8Array(iv)));
base64EncodedEncryptedFile = btoa(Uint8ArrayToString(new Uint8Array(encryptedFile)));
return [2 /*return*/, [base64EncodedSalt, base64EncodedIv, base64EncodedEncryptedFile,]];
}
});
});
}
function Uint8ArrayToString(uint8Array) {
// This exceeds the stack size for large files on Chrome:
// return String.fromCharCode.apply(null, uint8Array);
// Cannot just append to a string, because strings are constant
// and appending is O(N) runtime. So, we push to an array and
// then call join.
var arrayOfString = [];
for (var i = 0; i < uint8Array.length; i++) {
arrayOfString.push(String.fromCharCode(uint8Array[i]));
}
return arrayOfString.join('');
}
function base64ToString(s) {
if (typeof Buffer !== 'undefined') {
// Node.js environment for testing.
Expand Down

0 comments on commit 9ec7543

Please sign in to comment.