Activities & Lessons

Prime Numbers, Trapdoors, and Cracking Codes: A Math Puzzle—Part 1

5 Min Read
Shaped 2019 Blog Posts June Alexisblog Image 2

As students work through Pre-Algebra, Geometry, Algebra, and Calculus courses, you’ll show them plenty of real-world problems. One increasingly relevant topic that likely doesn’t come up in a day-to-day math class? Cybersecurity. In this two-part series, students will use number patterns to crack simple codes that are reflective of the encoding practices internet giants have taken on in password and data encryption. As you set the stage for this activity, encourage your class to research companies that have been victims of recent hacking schemes. This will make the math behind cyber protection that much more meaningful!

Your students have probably heard of—and shopped at—Under Armour, Delta Airlines, Panera Bread, Macy’s, Forever 21, Sears, and GameStop.

If your students research these companies and other giants, they will likely find that all of these companies have been victims of massive hacking schemes. Hackers have infiltrated the private information of countless customers over the past two years. Many other companies have been affected as well. Make a list of your class’s research findings on the board to show just how widespread hacking has become!

Consumer passwords, credit card numbers, identifying information, addresses, and more were released to malicious third parties due to hacks on the databases that these companies use. Even tech-giant Amazon has not been immune to information breaches in the 21st century. Thus, the relevance of online safety cannot be understated. Online safety is such a tricky, relevant topic that annually we celebrate Safer Internet Day in the United States to raise awareness not only about mindful online activity, but also about steps we can take to prevent unsolicited information sharing. Ask your students about their experiences with staying safe on the internet. Surprisingly—or maybe unsurprisingly to some—staying safe in the digital age has a lot to do with math.

Shaped 2019 Blog Posts June Alexisblog Image 1
What Is Hacking?

Before you and your students crunch the numbers, you should do a quick inventory of what it actually means to be threatened by a hacker or hacking scheme. Hacking has become a new-age buzzword, infiltrating children’s television (think of PBS Kids show Cyberchase) and even more colloquially in YouTube streams (“Life Hacks” and other tips). Yet hacking formally refers to unauthorized or illegal intrusions into a cyber system that result in the alteration of system features or security that deviates from the original purpose of the system. Your students may find other definitions, so come up with a class meaning that is in terms all your students can understand before moving on!

While students might be picturing a shadowy figure holed up in a dark corner of the world, delving into emails to track credit card numbers, in reality hacking takes many forms. People, government agencies, banks, social media accounts, and corporations can be targeted through cellphones, emails, apps, websites, or even ATM machines!

Some common dangers of hacking include the potential for identity theft, the ability to access personal or corporate e-mail accounts, and website security. Any company that has access to personal information uses a form of safeguard coding called encryption to lower the risk that consumers will be targeted by hackers. This is where the math comes in!

Encryption and Math

Simply stated, encryption allows computers to take plain text and encode it into a secret or indecipherable version of itself. This prevents hackers, or anyone with malicious intent, from reading information not intended for them. Share the following story with your students to give them some background on the evolution of this practice:

The idea of encoding information is not unique to the 21st century. In Roman times (over 2,000 years ago), famed military general Julius Caesar encrypted messages to his soldiers and generals by using a simple encryption called an alphabetic shift. To use an alphabetic shift, all letters from an intended message are shifted by the same fixed number of letters away in the alphabet. For example, the name J-U-L-I-U-S, with an alphabetic shift of four, now reads N-Y-P-M-Y-W. You can see how this shift is not difficult to perform, but would certainly confuse enemy forces looking for key intel!

This Caesar Cipher is one of the ways today’s computer science students and teachers start wrapping their minds around more complex encryption concepts. But deciphering the Caesar Cipher is not always as easy as enciphering. See if you can decode the messages below, all of which were encrypted using an alphabetic shift (but not necessarily the same alphabetic shift):


Struggling? See if you are able to decode a small word first, shifting each letter by the same amount until you are sure it’s an English word. Then, apply that shift to the remainder of the words. Got it already? Click here for the solutions!

To continue this activity, students can practice enciphering and deciphering messages using Caesar Ciphers of their choosing. After they encrypt two to three messages, have students trade with a partner and work out the cipher that their partner created. Keep your eyes out for Part 2 of this series, where we will cover more complicated cybersecurity techniques and the math behind them!


Find more lesson plans and classroom resources on Shaped.

Related Reading