AES-256-GCM encryption for secure messages with PBKDF2 key derivation.
import { encrypt } from 'toolmetry';| Function | Parameters | Returns | Description |
|---|---|---|---|
aesEncrypt | plaintext: string, secret: string | string | Encrypt text using AES-256-GCM (Node.js sync) |
aesDecrypt | encrypted: string, secret: string | string | Decrypt AES-256-GCM encrypted text (Node.js) |
aesEncryptAsync | plaintext: string, secret: string | Promise<string> | Async encrypt (browser + Node) |
aesDecryptAsync | encrypted: string, secret: string | Promise<string> | Async decrypt (browser + Node) |
import { aesEncrypt, aesDecrypt } from 'toolmetry';
const encrypted = aesEncrypt('Hello, secret!', 'my-password');
// "iv:authTag:ciphertext" (Base64 parts)
const decrypted = aesDecrypt(encrypted, 'my-password');
// "Hello, secret!"import { aesEncryptAsync, aesDecryptAsync } from 'toolmetry';
const encrypted = await aesEncryptAsync('Hello!', 'my-password');
const decrypted = await aesDecryptAsync(encrypted, 'my-password');
// "Hello!"