Decrypt a string with a secret using AES-256-GCM.
The input should be a URL-safe Base64 encoded string from encrypt. Extracts the salt, IV, and auth tag, then decrypts and decompresses the data.
URL-safe Base64 encoded ciphertext
The secret key for decryption
The decrypted plaintext
Error if decryption fails or auth tag is invalid
const encrypted = encrypt('Secret message', 'mySecret123')const decrypted = decrypt(encrypted, 'mySecret123')console.log(decrypted) // Secret message Copy
const encrypted = encrypt('Secret message', 'mySecret123')const decrypted = decrypt(encrypted, 'mySecret123')console.log(decrypted) // Secret message
Decrypt a string with a secret using AES-256-GCM.
The input should be a URL-safe Base64 encoded string from encrypt. Extracts the salt, IV, and auth tag, then decrypts and decompresses the data.