Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Nodejs snippet to decrypt intercom user submitted by Open sheet flow -
const masterkey = 'your-master-key';
// base64 decoding
const bData = Buffer.from(decoded, 'base64');
// convert data to buffers
const ivlen = 12;
const iv = bData.slice(0, ivlen);
const taglen = 16;
const tag = bData.slice(bData.length - taglen, bData.length);
const cipherLen = bData.length - taglen;
const cipherText = bData.slice(ivlen, cipherLen);
let hash = crypto.createHash('sha256').update(masterkey);
let key = Buffer.from(hash.digest("binary"), "binary");//buffer from binary string.
// AES 256 GCM Mode
const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);
// encrypt the given text
let decrypted = decipher.update(cipherText, 'binary', 'utf8');
decrypted +='utf8');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.