Topic · Applied

Symmetric cryptography

One shared key, used to lock and unlock. It is older, faster and simpler than public-key cryptography — and it still encrypts essentially all the data you send.

1. One key, both directions

Symmetric encryption uses a single key for both operations. Encrypt with it, decrypt with it. Everyone who needs to read the message needs that same key — which is simple, fast, and creates exactly one hard problem: how do you deliver the key in the first place?

That question went unanswered for most of history. It is what Diffie–Hellman finally solved in 1976.

2. XOR: the reversible operation

Almost all symmetric encryption is built on exclusive-or. XOR returns 1 when its two inputs differ, 0 when they match — and applying the same value twice returns the original.

message  1 0 1 1 0 0 1 0
key      1 1 0 1 0 1 1 0
cipher   0 1 1 0 0 1 0 0  ← XOR again with the key to recover the message

With a truly random key as long as the message, used once, this is a one-time pad — provably unbreakable. It is also impractical, because distributing a key as long as your data returns you to the original problem. Real ciphers use a short key to generate something that behaves convincingly like that long random stream.

3. Inside AES

The Advanced Encryption Standard, adopted in 2001, encrypts 128-bit blocks using keys of 128, 192 or 256 bits. Each block passes through a series of rounds — 10, 12 or 14 depending on key size — and each round applies four steps:

SubBytes

Substitute

Every byte is swapped via a fixed lookup table, adding non-linearity so the output cannot be unpicked algebraically.

ShiftRows

Shift

Rows are rotated by different amounts, spreading bytes apart.

MixColumns

Mix

Each column is transformed so every output byte depends on all four input bytes.

AddRoundKey

Combine

The block is XORed with a key derived from the main key for this round.

Claude Shannon named the goals: confusion (obscure the key–ciphertext relationship) and diffusion (spread each input bit across the whole output). After a few AES rounds, flipping one input bit changes about half the output bits.

AES has stood since 2001 with no practical break against the full cipher. Real failures come from implementation — timing leaks, reused keys, weak modes — not the algorithm.

4. Modes of operation

AES encrypts one 128-bit block. Real messages are longer, and the rule for chaining blocks matters more than most people expect.

ECB encrypts each block independently. Identical plaintext blocks produce identical ciphertext blocks, so patterns survive encryption — famously, an image encrypted in ECB mode is still recognisable. Do not use it.

CBC XORs each block with the previous ciphertext, hiding patterns, but provides no integrity: an attacker who cannot read your message may still be able to alter it meaningfully.

GCM encrypts and authenticates at once, producing a tag that detects any tampering. This is the modern default, and the reason TLS 1.3 dropped almost everything else.

The lesson: encryption without authentication is usually a bug. Confidentiality and integrity are separate properties, and you generally need both.

5. Why both kinds are used together

Symmetric encryption is roughly a thousand times faster than RSA, but needs a shared key. Public-key cryptography solves key distribution but is far too slow for bulk data.

So every real system uses both: public-key cryptography to agree on a symmetric key, then AES to encrypt the actual traffic. That is what happens each time you load an HTTPS page.

Frequently asked questions

What is symmetric encryption?
Encryption where the same key both encrypts and decrypts. It is fast and simple, but everyone who needs access must already have the key.
Is AES still secure?
Yes. There is no practical break against full AES. Real-world failures come from implementation problems such as key reuse, weak modes or timing side channels.
What is the difference between AES and RSA?
AES is symmetric and fast, used to encrypt data. RSA is asymmetric and slow, used to exchange keys and sign. Real systems use both together.
Which AES mode should be used?
GCM, because it provides authentication as well as encryption. ECB should never be used, and CBC alone leaves messages open to tampering.

Keep going

Protocols

How keys get agreed before AES takes over.

Read more →

Security definitions

What 'secure' formally means for a cipher.

Read more →

Cryptanalysis

How ciphers are attacked in practice.

Read more →