Last active
November 11, 2018 12:51
-
-
Save ejnshtein/f3b44957dd23b5b3ade60ad6ad780b20 to your computer and use it in GitHub Desktop.
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
const crypto = require('crypto') | |
const decrypt = (text, secret, algorithm = 'aes256') => { | |
const decipher = crypto.createDecipher(algorithm, secret) | |
let decrypted = decipher.update(text, 'hex', 'utf8') | |
decrypted += decipher.final('utf8') | |
return decrypted | |
} | |
/////////////////// | |
// const crypto = require('crypto') | |
const encrypt = (text, secret, algorithm = 'aes256') => { | |
const cipher = crypto.createCipher(algorithm, secret) | |
let crypted = cipher.update(text, 'utf8', 'hex') | |
crypted += cipher.final('hex') | |
return crypted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment