How to Use Math to Send Encrypted Messages

Learn what one-time pad encryption is, how it has been used throughout history, and how to use math to send your own encrypted messages.

Jason Marshall, PhD
5-minute read
Episode #30

How to Use Math to Send Encrypted Messages
Would you believe it’s possible to send someone a secret message secured with absolutely unbreakable encryption using only a bit of simple arithmetic? Well, it is—the solution is surprisingly simple and was used by British, German, and American spy agencies throughout World War II. Curious to know how it works? You’re in luck because today we’re taking our first steps into the world of secret-agent math.

Secret Agent Math, Part 1

Here’s the somewhat ridiculous but hopefully amusing scenario: Imagine you’re a secret agent working for your government’s top-secret espionage agency. You’re sitting alone in a restaurant when the waiter approaches your table and slides a small piece of folded paper in front of you. He indicates that the note was sent by a person seated across the room—you take a look and quickly recognize him to be a trusted colleague. The waiter leaves and you unfold the paper. Given your wealth of experience in these situations, you’re not at all surprised to find a senseless looking series of letters scrawled across the paper: “P–B–A”. Having taken stock of the situation, you realize that this sequence of letters is an encrypted message.

How to Decrypt a Secret Message

You pull out a small notepad that was issued to you before leaving on your trip. Its pages contain sequences of completely random numbers between zero and twenty-five. Armed with your notepad and the scrambled secret message, you begin the decryption process. Here’s how it works. Start by looking up the first random number in your notepad—in this case it’s two—and then cross it out so you don’t accidentally use it again. This first number is used to decrypt the first letter of your message. Beginning with the first letter in your message, “P,” count forward through the alphabet two characters—“Q” is one and “R” is two. So “R” is the first letter of your decoded message.

Okay, now that you’ve got that one figured out, all you have to do is repeat the process for each of the final two letters of your message. You look-up the next random number in your notepad—nineteen. So start at the letter “B”—the second letter in the scrambled message—and count forward nineteen letters until, eventually, you reach the letter “U”. This is the second letter in your decoded message. Finally, for the last letter “A,” you see the next random number in your notepad is thirteen. You count forward thirteen letters from “A” and arrive at “N.” So, you’ve now got your entire message decrypted—and it says: “R–U–N.” Run?!


About the Author

Jason Marshall, PhD

Jason Marshall is the author of The Math Dude's Quick and Dirty Guide to Algebra. He provides clear explanations of math terms and principles, and his simple tricks for solving basic algebra problems will have even the most math-phobic person looking forward to working out whatever math problem comes their way.