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.
One character
The letter A in the most common encoding corresponds to the byte 01000001. Let us choose the byte 00101101 as the key.
Text A 01000001
Key 00101101
XOR 01101100 → the letter “l”
Key 00101101
XOR 01000001 → “A” againApplying the same XOR with the same key gives back exactly the starting text.
Why a short key is not enough
If a long text is encrypted by always repeating the same one-byte key, identical letters in the text become identical encrypted bytes: it is a monoalphabetic substitution again, vulnerable to frequency analysis. Modern ciphers solve the problem by generating from the key a very long, never-repeating sequence, or by transforming each block differently through rounds and modes of operation.
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.
The pages of this topic
Back to the overviewSymmetric 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 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.