How to use node-aes-gcm - 4 common examples

To help you get started, we’ve selected a few node-aes-gcm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github andreas-mausch / whatsapp-viewer / decrypt-crypt12.js View on Github external
var databaseFilename = process.argv[2];
var keyFilename = process.argv[3];
var outputFilename = process.argv[4];

var crypt12 = fs.readFileSync(databaseFilename);
var keyfile = fs.readFileSync(keyFilename);

var iv = crypt12.slice(51, 67);
var key = keyfile.slice(126, 158);
var crypted = crypt12.slice(67, crypt12.length - 20);

console.log('Key: ', key);
console.log('Initialization vector: ', iv);
console.log('crypted: ', crypted);

var decryptedGzip = gcm.decrypt(key, iv, crypted, new Buffer([]), new Buffer(16)).plaintext;
console.log('decrypted (gzipped): ', decryptedGzip);

var decrypted = zlib.inflateSync(decryptedGzip);
console.log('decrypted: ', decrypted);

fs.writeFile(outputFilename, decrypted, { flag: 'wx' }, function (err) {
    if (err) throw err;
    console.log();
    console.log('written to ', outputFilename);
});

node-aes-gcm

AES GCM module for node.js that takes advantage of GCM authentication

MIT
Latest version published 4 years ago

Package Health Score

42 / 100
Full package analysis

Popular node-aes-gcm functions