Golden rule
Don't invent crypto. Use platform and vetted libraries.
Quick reference (Latacora-style)
| Need | Use |
|---|---|
| Symmetric encryption | AES-GCM (or ChaCha20-Poly1305) |
| Asymmetric sign | Ed25519 or RSA-2048+ |
| Key exchange | X25519 |
| Hash (integrity) | SHA-256 |
| Password storage | Argon2id or bcrypt |
| Random bytes | crypto.randomBytes / secrets module |
Hashing ≠ encryption
SHA-256(password) — fast, crackable. Use slow password hashes with salt.
TLS
Handled by platform — Networking topic. Don't terminate TLS yourself in app code.
Encryption at rest
Use KMS envelope encryption; don't hardcode AES keys in source.
Signing vs encryption
JWT signed (integrity) not encrypted (readable). JWE for encrypted tokens — rare complexity.
When interviewer asks "encrypt this field"
Ask: who needs to read it? search required? rotation? → drives KMS vs app-level vs DB TDE.
Cross-reference: Distributed Platform Security → KMS; Networking → TLS.
Further Reading
Hands-On Tasks (Optional)
Security design drills — threat modeling, auth flows, and incident playbooks. Assumes Networking (TLS) fundamentals.
- Choose password storage scheme10m
Compare bcrypt vs Argon2 vs scrypt. What not to use (MD5, SHA256 alone). Pepper + salt role.