Last updated: April 29, 2026
Symmetric crypto is fast, ubiquitous, and routinely misused.
Modes that matter
- AES-256-GCM — authenticated encryption with associated data; default choice
- ChaCha20-Poly1305 — alternative AEAD; faster on devices without AES-NI
- AES-CBC — legacy; no built-in auth (vulnerable to padding-oracle if MAC absent)
- AES-CTR — fast; needs separate MAC; nonce reuse catastrophic
- AES-ECB — never use; reveals patterns
Common pitfalls
- Nonce reuse with same key in GCM = key extraction
- Padding oracle attacks against CBC
- Hardcoded IVs / nonces
- Missing authentication (encrypt without HMAC)
The right pattern
# Python (cryptography library)
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import os
key = AESGCM.generate_key(bit_length=256)
aesgcm = AESGCM(key)
nonce = os.urandom(12) # 96 bits, never reused with this key
ciphertext = aesgcm.encrypt(nonce, plaintext, associated_data)
plaintext = aesgcm.decrypt(nonce, ciphertext, associated_data)
Module Quiz · 6 questions
Pass with 80%+ to mark this module complete. Unlimited retries. Each question shows an explanation.
Custom team training + practitioner advisory
Beyond the free academy — we run private workshops, vCISO advisory, and red-team exercises tailored to your stack. For Indian SMBs scaling past their first hire.