1var fs = require('fs');
2var crypto = require('crypto');
3
4var key = '14189dc35ae35e75ff31d7502e245cd9bc7803838fbfd5c773cdcd79b8a28bbd';
5var cipher = crypto.createCipher('aes-256-cbc', key);
6var input = fs.createReadStream('test.txt');
7var output = fs.createWriteStream('test.txt.enc');
8
9input.pipe(cipher).pipe(output);
10
11output.on('finish', function() {
12 console.log('Encrypted file written to disk!');
13});
14
1var aes256 = require('aes256'); var key = 'my passphrase';var plaintext = 'my plaintext message'; var encrypted = aes256.encrypt(key, plaintext);var decrypted = aes256.decrypt(key, encrypted); // plaintext === decrypted