I'm using nodejs to encrypt and decrypt aes-192-gcm
here's my code:
const encrypted = decrypt.encryptText('aes-192-gcm', 'FnpkKuIoqZL5B3tnE0Htmg==', '1z3FtB6OitmFOIsP', 'helloWorld', 'base64');
const de = decrypt.decryptText('aes-192-gcm', 'FnpkKuIoqZL5B3tnE0Htmg==', '1z3FtB6OitmFOIsP', encrypted, 'utf-8');
console.log(encrypted);
console.log(de);
Functions used:
function encryptText(cipher_alg, key, iv, text, encoding) {
var cipher = crypto.createCipheriv(cipher_alg, key, iv);
encoding = encoding || "binary";
var result = cipher.update(text, "utf8", encoding);
result += cipher.final(encoding);
return result;
}
function decryptText(cipher_alg, key, iv, text, encoding) {
const decipher = crypto.createDecipheriv(cipher_alg, key, iv);
encoding = encoding || "binary";
let result = decipher.update(text, encoding);
result += decipher.final();
return result;
}
The error I'm getting:
Unsupported state or unable to authenticate data