Created
March 1, 2018 18:04
-
-
Save gabefinch/ab3874fb9cfd8ab2982deb6188febd3a 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
function decrypt(text) { | |
const [ivStr, encodedStr] = text.split(':') | |
const initVector = new Buffer(ivStr, 'base64'); | |
const decipher = crypto.createDecipheriv( | |
'aes-256-cbc', CRYPTO_KEY, initVector | |
); | |
const encrypted = new Buffer(encodedStr, 'base64'); | |
let decrypted = Buffer.concat( | |
[decipher.update(encrypted), decipher.final()] | |
); | |
return decrypted.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment