Mirror of the Node.js AES-256-GCM middleware pattern with a SHA-256 key-derivation step (no PBKDF2, no salt). Format: 24-hex IV + 32-hex auth tag + base64 ciphertext. Runs entirely in your browser via the Web Crypto API — keys never leave your machine.
IP address geolocation
Check website security headers
Decode JSON Web Tokens
Encrypt & decrypt with AES-256
Check HTTP headers
Event structured data
The exact byte-for-byte output of the Node crypto middleware below — 12-byte IV hex + 16-byte GCM auth tag hex + base64 ciphertext, all concatenated as one string.
// Server-side encryption (Node crypto)
const derivedKey = crypto.createHash('sha256').update(secretKey).digest()
const iv = crypto.randomBytes(12)
const cipher = crypto.createCipheriv('aes-256-gcm', derivedKey, iv)
let enc = cipher.update(JSON.stringify(data), 'utf8', 'base64')
enc += cipher.final('base64')
const tag = cipher.getAuthTag()
return iv.toString('hex') + tag.toString('hex') + enc
SHA-256 turns an arbitrary-length secret into exactly 32 bytes — the size AES-256 needs. It's fast and deterministic. It's not a slow KDF, so it provides zero brute-force resistance — if your secret is weak, an attacker who steals a single ciphertext can crack it offline. For server-to-server middleware where the secret is a long random env var, that's acceptable. For user passwords, prefer PBKDF2 / scrypt / Argon2 with a salt.
AES-GCM is authenticated encryption — every ciphertext comes with a 16-byte tag that proves the ciphertext (and IV) haven't been tampered with. Decryption recomputes the tag and rejects the payload if it doesn't match. That's why the wrong key, a flipped bit, or a truncated payload all fail loudly instead of producing garbage plaintext. Web Crypto's decrypt() expects ciphertext + tag concatenated as one buffer — this tool reassembles them automatically.
Almost always one of:
Completely different stack: that tool is AES-256-CBC with OpenSSL KDF (salt-derived key+iv from a passphrase). This tool is AES-256-GCM with SHA-256(secret) as the literal key — no salt, no KDF iterations. GCM also adds authentication; CBC does not. Use whichever matches your middleware. If you're not sure, check the imports: import CryptoJS means the other tool, import crypto from 'node:crypto' means this one.