Simple AES-GCM encryption and decryption utilities powered by the Web Crypto API.
- 🔒 Encrypt text using AES-GCM.
- 🔓 Decrypt encrypted payloads back into plaintext.
- ⚡ Uses the native Web Crypto API (no external dependencies).
- 🌐 Works in Deno, Node.js (18+), and modern browsers.
- 📦 Small, tree-shakeable, and ESM-first.
-
Deno:
deno add jsr:@dep/aes
-
Node.js (18+) or Browsers:
npx jsr add @dep/aes
Then import as an ES module:
import { encrypt, decrypt } from '@dep/aes';
Encrypt text:
import { encrypt } from '@dep/aes';
const cipherText = await encrypt('MI4KP4050TD065782', 'dycxov-dYsxir-gykmi7');
console.log(cipherText);
// +vq7dCWJKmBKQN1Z50dzLyDjd5tpwCinAQKt/Mjfvj48g/EKjFZSQX6/2q1VDecrypt text:
import { decrypt } from '@dep/aes';
const plainText = await decrypt(
'+vq7dCWJKmBKQN1Z50dzLyDjd5tpwCinAQKt/Mjfvj48g/EKjFZSQX6/2q1V',
'dycxov-dYsxir-gykmi7',
);
console.log(plainText);
// MI4KP4050TD065782You can also use the namespace export:
import { aes } from '@dep/aes';
const encrypted = await aes.encrypt(
'MI4KP4050TD065782',
'dycxov-dYsxir-gykmi7',
);
const decrypted = await aes.decrypt(
'+vq7dCWJKmBKQN1Z50dzLyDjd5tpwCinAQKt/Mjfvj48g/EKjFZSQX6/2q1V',
'dycxov-dYsxir-gykmi7',
);MIT License – see LICENSE for details.
Author: Estarlin R (estarlincito.com)