Symmetric encryption · 04 Worked example

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.

terminale
Text   A    01000001
Key         00101101
XOR         01101100   → the letter “l”
Key         00101101
XOR         01000001   → “A” again

Applying 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.

Continue with
05 Weaknesses and attacks

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.

↑