Skip to content

Instantly share code, notes, and snippets.

@chirvo
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chirvo/1c3feb415ac3dd05a933 to your computer and use it in GitHub Desktop.
Save chirvo/1c3feb415ac3dd05a933 to your computer and use it in GitHub Desktop.
Quick and Dirty AES192 encryption with random 256-length password
crypto = require 'crypto'
__cipher = (data) ->
pwd = crypto.randomBytes(256).toString()
cipher = crypto.createCipher 'aes192', pwd
msg = []
msg.push cipher.update(data, 'binary', 'hex')
msg.push cipher.final('hex')
msg = msg.join('')
[msg, pwd]
__decipher = (data, pwd) ->
decipher = crypto.createDecipher 'aes192', pwd
msg = []
msg.push decipher.update(data, 'hex', 'binary')
msg.push decipher.final('binary')
msg.join('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment