Skip to content

Instantly share code, notes, and snippets.

@mekicha
Created May 28, 2017 10:57
Show Gist options
  • Save mekicha/32d23f9dd9a7e5cfa63cd8a3a4c6eddf to your computer and use it in GitHub Desktop.
Save mekicha/32d23f9dd9a7e5cfa63cd8a3a4c6eddf to your computer and use it in GitHub Desktop.
Compress and encrypt the file. To decrypt, see decrypt.js
fs.createReadStream(file)
.pipe(crypto.createDecipher('aes192', 'a_secret'))
.pipe(zlib.createGunzip())
.pipe(reportProgress)
.pipe(fs.createWriteStream(file.slice(0, -3)))
.on('finish', () => console.log('Done'));
const crypto = require('crypto');
fs.createReadStream(file)
.pipe(zlib.createGzip())
.pipe(crypto.createCipher('aes192', 'a_secret'))
.pipe(reportProgress)
.pipe(fs.createWriteStream(file + '.zz'))
.on('finish', () => console.log('Done'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment