Get your own Node server
const crypto = require('crypto');

// Encryption values (would be stored and retrieved securely in a real application)
const key = Buffer.from('1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', 'hex');
const iv = Buffer.from('123456789012123456789012', 'hex'); // 12 bytes for GCM
const encryptedData = 'af56c283ae95963c1e1877adb558d860';
const authTag = Buffer.from('1234567890abcdef1234567890abcdef', 'hex');
const associatedData = 'Additional data that was authenticated';

// Create decipher using AES-GCM
const decipher = crypto.createDecipheriv('aes-256-gcm', key, iv);

// Set the Additional Authenticated Data (AAD)
decipher.setAAD(Buffer.from(associatedData));

// Set the authentication tag
decipher.setAuthTag(authTag);

try {
  // Decrypt the data
  let decrypted = decipher.update(encryptedData, 'hex', 'utf8');
  decrypted += decipher.final('utf8');
  
  console.log('Decrypted Text:', decrypted);
  console.log('Authentication verified successfully');
} catch (error) {
  console.error('Authentication failed:', error.message);
  // If authentication fails, the decryption will throw an error
}

              
Decrypted Text: Secret message
Authentication verified successfully