Skip to content

Instantly share code, notes, and snippets.

@re5et
Created February 22, 2016 04:00
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 re5et/d9d775ed6149ccea451e to your computer and use it in GitHub Desktop.
Save re5et/d9d775ed6149ccea451e to your computer and use it in GitHub Desktop.
huh
const crypto = require('crypto');
const algorithm = 'aes-256-ctr';
const password = 'DERRRRP'
function encrypt(text){
const cipher = crypto.createCipher(algorithm, password)
const crypted = cipher.update(text,'utf8','hex')
return crypted;
}
function decrypt(text){
const decipher = crypto.createDecipher(algorithm, password)
const dec = decipher.update(text,'hex','utf8')
return dec;
}
const encrypted = encrypt('foo bar baz')
console.log(encrypted)
console.log(decrypt(encrypted))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment