Skip to main content
โ† Back to Mathematics samples
๐ŸงฎMathematicsยท15 minยทSample Lesson

Secret Codes: How Math Keeps Your Messages Safe

Every time someone shops online or sends a private message, math is secretly scrambling that information so hackers can't read it. This is called cryptography, and it all starts with a surprisingly simple math trick you can do yourself with just addition and remainders.

What You'll Learn

- How a Caesar cipher shifts letters using simple addition - What a 'key' is and why both sides need to agree on it - How remainders (modular math) keep the alphabet from running out - How to encode and decode your own secret message

The Caesar Shift: 2,000-Year-Old Math

Julius Caesar used a simple code to protect military messages: shift every letter forward by a fixed number. With a shift of 3, A becomes D, B becomes E, and so on. To send 'CAT,' you'd write 'FDW.' The receiver just shifts backward by 3 to undo it. The shift amount (3, in this case) is called the key -- both sender and receiver must know it, or the message stays scrambled.

What Happens When You Run Out of Letters?

With a shift of 3, what happens to X, Y, and Z? This is where math saves the day: we number A=0, B=1, C=2 ... Z=25, then use remainders (called 'mod 26,' since there are 26 letters). To shift X (23) by 3: 23+3=26, and 26 mod 26 = 0, which is A! So X shifts to A, wrapping back around to the start of the alphabet like a clock face.

Vocabulary

Cipher: a method for turning readable text into scrambled text. Key: the secret number or rule needed to encode and decode a message. Modular math (mod): math that 'wraps around' after reaching a certain number, like a clock going from 12 back to 1.

Why Simple Ciphers Aren't Enough Anymore

A Caesar cipher only has 25 possible keys, so a computer can try every single one in a fraction of a second -- this is called a 'brute force' attack. That's why modern encryption, like the RSA algorithm used to protect your bank's website, relies on much harder math: multiplying two enormous prime numbers together. Multiplying them is fast, but figuring out the two original primes from the giant result would take even a powerful computer longer than the age of the universe. That one-way difficulty is what actually keeps your data safe today.

Try Cracking It
Try Cracking It

If you saw the scrambled word 'NHBV' and knew it was a Caesar cipher with a shift of 3, could you decode it? Shift each letter BACK by 3: N->K, H->E, B->Y, V->S. The answer is 'KEYS'!

โ“

In a Caesar cipher with a shift of 3, what does the letter 'X' become, and why?

โ“

Why is a simple Caesar cipher considered weak by modern standards?

๐ŸŽฏ

Send a Secret Message

Pick a shift key between 1 and 25. Write a short message (at least 5 words) and encode it letter by letter using your shift, wrapping around the alphabet with mod 26 when needed. Give your encoded message AND your shift key to a partner, and have them decode it by shifting backward. Then decode a message they send back to you. Write down both original messages and both encoded versions to turn in.

Want to keep learning?

Sign up for free to access the full curriculum โ€” all subjects, all ages.

Start Learning Free
Secret Codes: How Math Keeps Your Messages Safe | Free Sample | HYVE CARES | HYVE CARES