What encryption does
Encryption scrambles readable data (plaintext) into unreadable data (ciphertext) using a key. Only someone with the right key can turn it back. It protects confidentiality.
Two flavours
Symmetric: one shared key 🔑
The same key locks and unlocks.
- ✅ Very fast, so it’s good for large amounts of data
- ❌ Hard part: sharing the key safely
- Example: AES (the modern standard)
Asymmetric: a key pair 🔑🔓
Each person has a public key (share it with anyone) and a private key (never share it).
- Encrypt with someone’s public key → only their private key can decrypt
- Sign with your private key → anyone can verify with your public key
- ✅ Solves the key-sharing problem
- ❌ Much slower
- Examples: RSA, ECC
Best of both
Real systems (like TLS, the “S” in HTTPS) use asymmetric crypto to safely agree on a symmetric session key, then use that fast symmetric key for the actual data.
Three states of data
| State | Example | Protection |
|---|---|---|
| At rest | Files on a disk, database, backup | Full-disk encryption, database encryption |
| In transit | Data crossing a network | TLS/HTTPS, VPNs |
| In use | Data being processed in memory | Access controls, secure enclaves |
The browser padlock
The padlock means your connection to that site is encrypted with TLS. It does not mean the site is honest: phishing sites get padlocks too!
Golden rule
Never invent your own encryption. Use well-tested, standard algorithms and libraries. Security depends on keeping the key secret, not the algorithm.