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

3 Min Read
Shaped 2019 Blog Posts June Alexisblog Image 2 4c284b73b1b0834026b992b9ac93d6bd

In Part 1 of our series on cryptography, we discovered how information can be enciphered using math and patterns. If you haven’t checked out Part 1 of this series, click here for our post and student worksheet.

We previously had your students practice using an early variation of the Caesar Cipher, which encodes alphabetic characters by adding or subtracting by a desired alphabetic shift. But encryption in today’s online world is actually based on a more complex mathematical algorithm called RSA enciphering. RSA enciphering uses a combination of mathematical operations—think exponents and really large prime numbers—to convert plain text to ciphertext, its encoded counterpart.

Explain to your students that the size of the encrypted information is key to keeping sensitive data protected. Websites use “bits,” short for binary digits, to measure the lengths of encoded versions of passwords and other important consumer information.

Bits become exponentially more difficult to crack the longer they become. A 56-bit key compared with a 64-bit key doesn’t initially seem that different based on a traditional understanding of math. But the 64-bit key is actually 256 times more difficult to crack compared with the 56-bit key. Your favorite websites use even longer encryption codes! Google and Gmail encrypt your data with 1024-bit keys. Facebook does, too. You’re extra safe on Twitter: their 2048-bit key would take over a million years to hack by hand. Astute hackers, of course, can do it more quickly using advanced technology.

The RSA algorithm works because it is what computer scientists label as a trapdoor: easy to fall in but challenging to get out. The basics of the RSA encryption are as follows: A computer chooses and multiplies two large prime numbers together. The resulting number is given to a second computer system. If you asked this second system to tell you what prime numbers you multiplied to construct it, the computer would have a tough time determining exactly which prime numbers were multiplied together to generate the larger product. This is the trapdoor: it is easy to encipher a message using the RSA algorithm, but much more challenging to decipher it.

A simpler encryption trapdoor is listed in the attached PDF. See if your students can follow the encryption of the message GOOD DOG. Easy enough, right? Can your students come up with a rule to decrypt that same message? That’s where the trapdoor applies!

Download this student activity as a PDF.

Can your students encode the seasonal phrases below by using the cube and remainder rule? Can they come up with a way to outsmart the trapdoor and decode the messages, too? Check their answers when they're done here!


Now that your students know the amount of math and logic that go into enciphering, they can hopefully feel safer in the digital world! Share these other ways they can ensure their information is protected online.

  1. Create strong passwords and don’t use the same password for multiple sites.
  2. Try to avoid using public Wi-Fi whenever possible—these networks are easier to hack!
  3. Be cautious about sharing personal information on social media sites, like an address, place of birth, or birthday. These pieces of information can be used to steal your identity.
  4. Use a firewall or site adviser to determine if a website is illegitimate while online shopping or creating an account.
  5. Turn on automatic updates so your computer and internet browser have the most updated firewalls available.

Here’s to a safely encrypted 2019!


Find more lesson plans and classroom resources on Shaped.

Related Reading