From bc7ced6b7b42e4cf88d66596af85a3898303614b Mon Sep 17 00:00:00 2001 From: Zhen Yu Yong Date: Thu, 25 Jun 2020 20:07:38 +0800 Subject: [PATCH] concat ciphertexts in browser.js for encryption/decryption --- browser.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/browser.js b/browser.js index 11cb609..b5bae33 100644 --- a/browser.js +++ b/browser.js @@ -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])); } } });