concat ciphertexts in browser.js for encryption/decryption

This commit is contained in:
Zhen Yu Yong 2020-06-25 20:07:38 +08:00 committed by Jordan Baczuk
parent 4fc0853915
commit bc7ced6b7b

View File

@ -78,13 +78,15 @@ function getAes(op) {
} else {
if (op === 'encrypt') {
var cipher = nodeCrypto.createCipheriv('aes-256-cbc', key, iv);
cipher.update(data);
resolve(cipher.final());
var firstChunk = cipher.update(data);
var secondChunk = cipher.final();
resolve(Buffer.concat([firstChunk, secondChunk]));
}
else if (op === 'decrypt') {
var decipher = nodeCrypto.createDecipheriv('aes-256-cbc', key, iv);
decipher.update(data);
resolve(decipher.final());
var firstChunk = decipher.update(data);
var secondChunk = decipher.final();
resolve(Buffer.concat([firstChunk, secondChunk]));
}
}
});