Skip to content

Instantly share code, notes, and snippets.

@gabefinch
Created March 1, 2018 18:04
Show Gist options
  • Save gabefinch/ab3874fb9cfd8ab2982deb6188febd3a to your computer and use it in GitHub Desktop.
Save gabefinch/ab3874fb9cfd8ab2982deb6188febd3a to your computer and use it in GitHub Desktop.
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