WeCodeAcademy

Classic Ciphers and Why They Fail

Encryption scrambles data with a key so only key holders can read it. Looking at old ciphers shows why modern ones are built the way they are.

The Caesar cipher shifts each letter a fixed number of places: with a shift of 3, A becomes D. There are only 25 possible keys, so an attacker simply tries them all, and the letter pattern (e is the commonest English letter) betrays it too.

Lesson: a secure cipher needs a huge key space and must hide patterns. Never invent your own cipher; use well-tested standard ones.

Examplepython
Open in editor »
Quick check

Why is the Caesar cipher easy to break?

Your turn: write the code

Encrypt 'Attack at dawn' with a Caesar shift of 5 (keep spaces and capitals) and print the result.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.