diff --git a/spec/test/chachaSpec.js b/spec/test/chachaSpec.js --- a/spec/test/chachaSpec.js +++ b/spec/test/chachaSpec.js @@ -34,7 +34,7 @@ describe("Chacha",function(){ describe("encrypt",function(){ it("should correctly encrypt an example text",function(){ let ciphertext=[110,46,53,154,37,104,249,128,65,186,7,40,221,13,105,129,233,126,122,236,29, 67,96,194,10,39,175,204,253,159,174,11,249,27,101,197,82,71,51,171,143,89,61,171,205,98,179,87,22, 57,214,36,230,81,82,171,143,83,12,53,159,8,97,216,7,202,13,191,80,13,106,97,86,163,142,8,138,34, 182,94,82,188,81,77,22,204,248,6,129,140,233,26,183,121,55,54,90,249,11,191,116,163,91,230,180,11, 142,237,242,120,94,66,135,77]; - expect(encrypt(str2utf8(plaintext),key,nonce2)).toEqual(nonce2.concat(ciphertext)); + expect(encrypt(str2utf8(plaintext),key,nonce2)).toEqual([nonce2,ciphertext]); }); }); @@ -45,7 +45,8 @@ describe("Chacha",function(){ for(let i=0;i<16;i++){key.push(Math.floor(Math.random()*256));} let nonce=[]; for(let i=0;i<8;i++){nonce.push(Math.floor(Math.random()*256));} - expect(decrypt(encrypt(text,key,nonce),key)).toEqual(text); + let [_,ciphertext]=encrypt(text,key,nonce); + expect(decrypt(ciphertext,key,nonce)).toEqual(text); }); });