I'm trying to decrypt data using a key and the AES-JS library. Whenever I put a 16 bytes key I get the following error:
Error: "invalid ciphertext size (must be 16 bytes)"
I already tried to change the key to non-16 bytes value but then I get this error:
Error: "invalid key size (must be 16, 24 or 32 bytes)"
Here is my code so far :
export const getEventBlockData = (cm, eventBlockData) => {
const encryptedBlockBuf = Buffer.from(eventBlockData, 'base64');
const aes = new aesjs.AES(aesjs.utils.utf8.toBytes('1111111111111111'));
const decryptedBlockBuffer = new Buffer(aes.decrypt(encryptedBlockBuf));
};
The part that generates an error is the last line with aes.decrypt(...
NB : the cm var is supposed to be the key but for testing purposes i replaced it by a string "1111111111111111" and the eventBlockData is the buffer i'm trying to decrypt, he has the following form :
Event Block Data :{"type":"Buffer","data":[49,56,53,50,55,51,53,49,50,50,48,48,48,49,48,48,48,48,49]} cm-service.js:61
Encrypted Block buff :{"type":"Buffer","data":[49,56,53,50,55,51,53,49,50,50,48,48,48,49,48,48,48,48,49]}
Thanks for your time! :)