title: zlib fails to decompress gzip data
body: <p>I'm using the <code>zlib</code> node module to compress data, encrypt it with the <code>crypto</code> module and then safe it to a file. Reading and writing the file works fine, as well as encrypting and decrypting the data, but how ever when I try to decompress the data with <code>zlib.unzip</code> it returns the following error.</p>
  
  <pre><code>Error: incorrect header check at Zlib.zlibOnError [as onerror] (zlib.js:153:17) errno: -3, code:'Z_DATA_ERROR'
  </code></pre>
  
  <p>I've already checked, whether the data read from the file is the same as written to it, which is the case. Using <code>zlib.gunzip</code> instead to bypass the automated header detection of zlib doesn't change anything.</p>
  
  <pre><code>function encrypt(data, enc) {
    zlib.gzip(data, (err, compressed) =&gt; {
      let cipher = crypto.createCipheriv(enc.algorithm, enc.key, enc.iv);
      compressed = cipher.update(compressed.toString(), 'utf8', 'base64') + cipher.final('base64');
      fs.writeFile('passwords', compressed, (err) =&gt; {
        if (err) throw err;
      });
    });
  }
  
  
  function decrypt(enc) {
    fs.readFile('passwords', (err, data) =&gt; {
      if (err) throw err;
      let decipher = crypto.createDecipheriv(enc.algorithm, enc.key, enc.iv);
      data = decipher.update(data.toString(), 'base64', 'utf8') + decipher.final('utf8');
      zlib.unzip(data, (err, uncompressed) =&gt; { // THIS LINE SEEMS TO THROW THE ERROR
        if (err) console.warn(err);
        console.log(uncompressed);
      });
    });
  }
  </code></pre>
  
  <p><strong>Update:</strong>
  I've been trying to investigate this problem further, because it's still appearing and i would really like to include compression as a feature.</p>
  
  <p>However what i found out so far, is that apparently the error only occurs, when using <code>zlib</code> and <code>crypto</code> in combination, both work fine on their own. </p>
  
  <p>Apparently <code>zlib</code> got a problem with <code>crypto</code> tinkering with the compressed data, because switching the order of them seems to solve the issue somehow. But compressing more or less random data, <code>crypto</code> returns after encryption, doesn't makes much sense.</p>
  
  <p>Maybe somebody got an idea on that?</p>
  
  <p><strong>Update 2:</strong>
  I again looked further into this and it appears, the decrypted data doesn't fit the encrypted data. However it is being decrypted properly and <code>crypto</code> doesn't throw any errors. That's probably why <code>zlib</code> isn't abled to unzip the data.</p>