Symmetric encryption: one key to lock and to unlock
How symmetric encryption works, the difference between block and stream ciphers, the key distribution problem, the maths of XOR, attacks and the algorithms used today.
In symmetric encryption whoever encrypts and whoever decrypts use the same key, like a safe with a single combination. It is the oldest form of cryptography — the Caesar cipher was already symmetric — and it is still what protects almost all data today: files on a laptop disk, the traffic of an HTTPS site, encrypted calls, archives in the cloud.
Its strength is speed: modern symmetric algorithms encrypt gigabytes per second. Its limit is the key problem: sender and recipient must share the key before communicating, and must keep it secret. For centuries this required couriers, ciphers written in booklets, meetings in person. The modern solution is to combine symmetric encryption with public-key cryptography.
Two families
- Block ciphers
- They encrypt fixed-size blocks, for example 128 bits, with a complex transformation repeated over several rounds. The main example is AES.
- Stream ciphers
- They generate a long pseudo-random sequence from the key and combine it with the data bit by bit. The main example is ChaCha20.
Modern symmetric encryption follows Kerckhoffs’s principle: the algorithm is public, only the key is secret. For key exchange see public-key cryptography and Diffie-Hellman.
The pages of this topic
Symmetric encryption: how it works
How block and stream ciphers work, modes of operation and authenticated encryption.
Symmetric encryption: history
From the scytale and the Caesar cipher to polyalphabetic ciphers, from rotor machines to DES and AES.
Symmetric 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.