Skip to content

Instantly share code, notes, and snippets.

@leonguyen
Created March 10, 2014 02:18
Show Gist options
  • Select an option

  • Save leonguyen/9458434 to your computer and use it in GitHub Desktop.

Select an option

Save leonguyen/9458434 to your computer and use it in GitHub Desktop.
encrypt/decrypt
global.encrypt = function(text){
var cipher = require('crypto').createCipher('aes-256-cbc','sint')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
global.decrypt = function(text){
var decipher = require('crypto').createDecipher('aes-256-cbc','sint')
var decrypted = decipher.update(text,'hex','utf8')
decrypted += decipher.final('utf8');
return decrypted;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment