Skip to content

Instantly share code, notes, and snippets.

@cmbaughman
Created March 12, 2014 01:28
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 cmbaughman/9498875 to your computer and use it in GitHub Desktop.
Save cmbaughman/9498875 to your computer and use it in GitHub Desktop.
var crypto = require('crypto');
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq');
var crypted = cipher.update(text,'utf8','hex');
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq');
var dec = decipher.update(text,'hex','utf8');
dec += decipher.final('utf8');
return dec;
}
var hw = encrypt("candoris");
console.log("hw: " + hw);
hw = decrypt(hw);
console.log(hw);
@cmbaughman
Copy link
Author

To Do: Also check into the crypto.createCipervi(algo, salt, vi) maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment