title: Encrypt compressed data using zlib and cryptojs
body: <p>I'm in node js, trying to compress an object using <strong>zlib.deflate</strong> and then encrypt it using <strong>cryptojs</strong> <strong>AES</strong>.</p>
  <p>Then, when I try to get the original value, I fail on the <strong>zlib.inflate</strong> call with the error: <strong>&quot;incorrect header check&quot;</strong>.</p>
  <pre><code>const zlib = require('zlib');
  const { AES, enc } = require('crypto-js');
  
  const obj = {
      a: &quot;a&quot;,
      b: &quot;b&quot;
  };
  
  const inputToDeflate = JSON.stringify(obj);
  const compressed = zlib.deflateSync(inputToDeflate);
  const encrypted = AES.encrypt(compressed.toString(), 'f11').toString();
  
  
  const decrypted = AES.decrypt(encrypted, 'f11');
  const decompressed = zlib.inflateSync(decrypted.toString(enc.Utf8));
  </code></pre>