title: How to fix 'invalid ciphertext size' error in Javascript ? (aes)
body: <p>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: </p>
  
  <blockquote>
    <p>Error: "invalid ciphertext size (must be 16 bytes)"</p>
  </blockquote>
  
  <p>I already tried to change the key to non-16 bytes value but then I get this error: </p>
  
  <blockquote>
    <p>Error: "invalid key size (must be 16, 24 or 32 bytes)"</p>
  </blockquote>
  
  <p>Here is my code so far :</p>
  
  <pre><code>export const getEventBlockData = (cm, eventBlockData) =&gt; {
    const encryptedBlockBuf = Buffer.from(eventBlockData, 'base64');
    const aes = new aesjs.AES(aesjs.utils.utf8.toBytes('1111111111111111'));
    const decryptedBlockBuffer = new Buffer(aes.decrypt(encryptedBlockBuf));
  };
  </code></pre>
  
  <p>The part that generates an error is the last line with <code>aes.decrypt(...</code></p>
  
  <p>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 : </p>
  
  <pre><code>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]}
  </code></pre>
  
  <p>Thanks for your time! :)</p>