Created
February 22, 2016 04:00
-
-
Save re5et/d9d775ed6149ccea451e to your computer and use it in GitHub Desktop.
huh
This file contains hidden or 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
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