Symmetric encryption: how it works
How block and stream ciphers work, modes of operation and authenticated encryption.
- 01
Generate the key
A random sequence of 128 or 256 bits, produced by a cryptographically secure generator.
- 02
Share it
Over a secure channel or, more often, with a public-key protocol.
- 03
Encrypt
The algorithm turns plaintext into ciphertext using the key and, almost always, a unique value for each message (initialisation vector or nonce).
- 04
Authenticate
Modern encryption adds an authentication code that makes any modification detectable.
- 05
Decrypt
The recipient, with the same key, checks authenticity and recovers the plaintext.
Blocks and streams compared
| Aspect | Block cipher | Stream cipher |
|---|---|---|
| Unit of work | Fixed blocks, for example 16 bytes | Individual bits or bytes |
| Use | With a mode of operation (CBC, CTR, GCM…) | Directly, combining data and keystream |
| Examples | AES, the old DES | ChaCha20, the old RC4 |
| Typical risk | Wrong mode, such as ECB | Reusing the keystream |
Symmetric encryption: history
From the scytale and the Caesar cipher to polyalphabetic ciphers, from rotor machines to DES and AES.
The pages of this topic
Back to the overviewSymmetric encryption: the maths
XOR and its properties, the size of the key space, brute force and the problem of the number of keys among many users.
Symmetric encryption: worked example
An example of XOR encryption on a single character and on a word, to see how the same key encrypts and decrypts.
Symmetric encryption: weaknesses and attacks
Brute force, reuse of keys and nonces, wrong modes, side channels and poor key management: how symmetric encryption is attacked.
Symmetric encryption today
Where symmetric encryption is used every day and which algorithms are recommended: AES-GCM, ChaCha20-Poly1305, disk encryption.
Symmetric encryption: try it yourself
Exercises on XOR, counting keys and brute force, with solutions.
Symmetric encryption: frequently asked questions
Short answers to the most common doubts about symmetric encryption.