node package manager

crypt-decrypt

stream wrapper around node's cryto 'createCipher' (Encrypt) and 'createDecipher' (Decrypt) methods

crypt-decrypt

a node streams wrapper around node's crypto createCipher (Encrypt) and createDecipher (Decrypt) methods

npm install crypt-decrypt
var source = require('stream').PassThrough(),
    cryptDecrypt = require('crypt-decrypt'),
    encrypt = new cryptDecrypt.Encrypt({
      pass : 'secret'
    }),
    decrypt = new cryptDecrypt.Decrypt({
      pass : 'secret'
    })
 
var input = new Buffer(
  ['this is a test',
    ' of the emergency broadcast system',
    ' if this had been a real emergency',
    ' you would have been instructed to...'
  ].reduce(function(a,b) {
    return a + b
  }), 'ascii')
 
source
  .pipe(encrypt)
  .pipe(decrypt)
  .pipe(process.stdout)
 
source.push(input)
source.push(null)

By default if you are only required to pass in options.pass. The rest of the values will be defaulted if not supplied.

Below are the defaults of every option :

  • algorithm (alg) : aes-256-cbc
  • inputEncoding (ine) : buffer
  • encoding (enc) : buffer
  • password (pass) : NO DEFAULT will throw if not supplied

See node's crypto module for more details on encoding.

npm test

MIT