title: Decrypt large file with crypto nodejs
body: <p>I am decripting a large file (<strong>450mb</strong>). </p>
  
  <p>I am reading the file with <strong>fs.createReadStream</strong> and decrypting with <strong>crypto-js</strong>.</p>
  
  <p>The file has been encrypted in UTF8.</p>
  
  <p>The contents of the file is JSON.</p>
  
  <p><strong>MY FUNCTION:</strong></p>
  
  <pre><code>function decryptFile(srcDir, fileName, destDir) {
  
      let encryptedPath = path.join(srcDir, fileName);
      let decryptedPath = path.join(destDir, fileName).replace('.xam', '.json');
  
      console.log('DECRYPTING XAM FILE ' + encryptedPath + ' TO ' + decryptedPath);
  
      const input = fs.createReadStream(encryptedPath);
  
      input.once('readable', () =&gt; {
  
          const decipher = crypto.createDecipher('xxx-xxx-xxx', 'XxxX');
  
          const output = fs.createWriteStream(decryptedPath);
  
          input.pipe(decipher).pipe(output).on('finish', () =&gt; {
  
              console.log('FILE DECRYPTED');
  
          }).on('error', error =&gt; {
  
              console.log(error);
  
          });
  
      });
  }
  </code></pre>
  
  <p><em>UPDATE</em>
  <strong>ERROR:</strong></p>
  
  <pre><code>Error: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
      at Decipher._flush (crypto.js:158:28)
      at Decipher.prefinish (_stream_transform.js:137:10)
      at emitNone (events.js:106:13)
      at Decipher.emit (events.js:208:7)
      at prefinish (_stream_writable.js:602:14)
      at finishMaybe (_stream_writable.js:610:5)
      at afterWrite (_stream_writable.js:464:3)
      at onwrite (_stream_writable.js:454:7)
      at Decipher.afterTransform (_stream_transform.js:90:3)
      at Decipher._transform (crypto.js:153:3)
  </code></pre>
  
  <p><em>UPDATE</em> <em>Title</em></p>