Last active
August 29, 2015 14:09
-
-
Save chirvo/1c3feb415ac3dd05a933 to your computer and use it in GitHub Desktop.
Quick and Dirty AES192 encryption with random 256-length password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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