Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
let firstChunk = cipher.update(data);
let 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());
let firstChunk = decipher.update(data);
let secondChunk = decipher.final();
resolve(Buffer.concat([firstChunk, secondChunk]));
}
}
});
Expand Down
8 changes: 8 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ describe("ECIES", function() {
});
});

it("should encrypt and decrypt with message size > 15", function() {
Comment thread
YZhenY marked this conversation as resolved.
return eccrypto.encrypt(publicKeyA, Buffer.from("message size that is greater than 15 for sure =)")).then(function(enc) {
return eccrypto.decrypt(privateKeyA, enc);
}).then(function(msg) {
expect(msg.toString()).to.equal("message size that is greater than 15 for sure =)");
});
});

it("should encrypt with compressed public key", function() {
return eccrypto.encrypt(publicKeyBCompressed, Buffer.from("test"), encOpts)
.then(function(enc) {
Expand Down