What is encryption?
Encryption turns plaintext into ciphertext with a key, and back again. Unlike hashing, it is designed to be reversed — by exactly the people holding the right key.
In this lesson
- Describe encryption, decryption, key and nonce
- Tell symmetric and asymmetric encryption apart
- Give three real systems that rely on encryption
Readable only with the key
An encryption algorithm takes plaintext, a key and (usually) a nonce — a value that must never repeat for the same key — and produces ciphertext. Decryption with the correct key restores the plaintext; with the wrong key you get noise.
Example · Where encryption already protects you
HTTPS on every website you visit, the lock screen on your phone (full-disk encryption), Signal and WhatsApp messages, cloud backups, and the encrypted volume on your laptop drive — all of it is symmetric encryption under the hood, usually AES-GCM.
- One key, shared secretly
- Very fast — used for bulk data
- Problem: how do you share the key?
- AES-256-GCM is the modern default
- Two keys: public + private
- Slow — used for key exchange and signatures
- Solves key distribution
- X25519 / Ed25519 are the modern defaults
from cryptography.fernet import Fernet\n\nkey = Fernet.generate_key() # symmetric key\nfernet = Fernet(key)\n\nciphertext = fernet.encrypt(b"meet at noon")\nprint(ciphertext)\nprint(fernet.decrypt(ciphertext)) # b"meet at noon"
Encryption without key management is theatre
Algorithms rarely fail — key handling does. Hard-coded keys in source, keys in URLs, or screenshots of recovery codes leak ciphertext as easily as plaintext. Rotate, store and transport keys deliberately.
Start with a broken cipher
The Caesar cipher is encryption with a key of 1-25. Break it by brute force in the lab, then compare with AES.
Is encryption reversible? Isn't that weak?
Reversibility is the point: encryption protects confidentiality, hashing protects integrity. Different jobs, different tools.
What is a nonce?
A number used once. In AES-GCM reusing a nonce with the same key destroys confidentiality and authenticity — modern libraries enforce unique nonces for you.