Skip to content

Instantly share code, notes, and snippets.

@tuliofaria
Created December 8, 2017 20:47
Show Gist options
  • Save tuliofaria/cf5aacf85509a2e1f71b39e170f97ee1 to your computer and use it in GitHub Desktop.
Save tuliofaria/cf5aacf85509a2e1f71b39e170f97ee1 to your computer and use it in GitHub Desktop.
Crypt e Decrypt Files
const fs = require('fs')
const crypto = require('crypto')
const alg = 'aes-256-ctr'
const passwd = 'abcdabcd'
const read = fs.createReadStream('input.txt')
const write = fs.createWriteStream('output.txt')
const cipher = crypto.createCipher(alg, passwd)
read.pipe(cipher).pipe(write)
const fs = require('fs')
const crypto = require('crypto')
const alg = 'aes-256-ctr'
const passwd = 'abcdabcd'
const read = fs.createReadStream('output.txt')
const write = fs.createWriteStream('decrypted.txt')
const cipher = crypto.createDecipher(alg, passwd)
read.pipe(cipher).pipe(write)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment