title: Node.js encrypts large file using AES
body: <p>I try to use following code to encrypt a file of 1 GB. But Node.js abort with "FATAL ERROR: JS Allocation failed - process out of memory". How can I deal with it?</p>
  
  <pre><code>var fs = require('fs');
  var crypto = require('crypto');
  var key = "14189dc35ae35e75ff31d7502e245cd9bc7803838fbfd5c773cdcd79b8a28bbd";
  var cipher = crypto.createCipher('aes-256-cbc', key);
  var file_cipher = "";
  var f = fs.ReadStream("test.txt");
  f.on('data', function(d) {
      file_cipher = file_cipher + cipher.update(d, 'utf8', 'hex');
  });
  f.on('end', function() {  
      file_cipher = file_cipher + cipher.final('hex');
  });   
  </code></pre>