# Crack the Code! Make a Caesar Cipher

## Summary

Key Concepts
Cryptography
Credits
Ben Finio, PhD, Science Buddies

## Introduction

If you need to send a secret message to a friend, how could you prevent other people from reading it? One way is to encrypt the message, or use a secret code that only you and your friend know. Try this activity to learn how to create your own "Caesar cipher," a popular type of code that is easy to learn.

This activity is not recommended for use as a science fair project. Good science fair projects have a stronger focus on controlling variables, taking accurate measurements, and analyzing data. To find a science fair project that is just right for you, browse our library of over 1,200 Science Fair Project Ideas or use the Topic Selection Wizard to get a personalized project recommendation.

## Background

Cryptography is the study of writing or solving secret codes that are used for secure communication. Historically, codes have been used by politicians, spies, and countries at war to prevent their enemies from knowing what they're up to. Many of the earliest codes, or "ciphers," like the one you will create in this project, were easy to create by hand. However, modern cryptography is essential in computer science for keeping everything from emails to bank account information secure.

One of the earliest and most widely known ciphers is the Caesar Cipher, named after Julius Caesar. It is a simple form of a "substitution cipher" where you replace each letter of the alphabet with another letter by shifting the whole alphabet a certain number of letters (wrapping around to the beginning once you reach the end). For example, if you shift each letter by 3 spaces, then the alphabet looks like this:

Plain:    ABCDEFGHIJKLMNOPQRSTUVWXYZ

Cipher:   XYZABCDEFGHIJKLMNOPQRSTUVW

So, when you write your message, the letter "A" gets replaced with "X", "B" gets replaced with "Y", and so on. For example, the word "hello" becomes:

Plain:    HELLO

Cipher:   EBIIL

In order to decode your message, you need to share the "key" (the number 3) with your friend first. After that, you can send messages that are written in cipher, so other people can't read them!

## Materials

• Pencil and paper
• At least one other person

## Instructions

1. Explain the concept of a Caesar cipher to a friend, or have them read the background section of this activity.
2. Write down the alphabet from A to Z.
3. Pick a number from 1 to 25 (if you use 26, you will just wind up with the original alphabet). This number is your key.
4. Shift the entire alphabet by the number you picked and write it down below your original alphabet (as shown in the Background section).
5. Pick a message to write to your friend. It might be easiest to start out with a simple message (like a single word or phrase) before you try longer sentences or paragraphs.
6. Write down your encoded message using your shifted alphabet. If it helps, write down your plain-text message first, then encode it one letter at a time (like the "hello" example in the background). Just make sure the piece of paper you give your friend only has the encoded message!
7. Give your friend the encoded message and tell them the key (don't write the key down – that's like writing down your computer password, a big security no-no!).
8. See if your friend can decrypt your message. If it helps for the first try, let them work backwards using the original and shifted alphabets you wrote down. Using the example from the background, the letter "x" becomes "a", "y" becomes "b", and so on.

Extra: try finding a third person who does not know what a Caesar cipher is. Can they crack your code if they "intercept" your message?

Extra: what if the person who intercepts your message knows about Caesar ciphers? Does that make it easier to crack the code? Since there are only 25 possible keys, Caesar ciphers are very vulnerable to a "brute force" attack, where you simply try each possible combination of letters. This might take some patience for a human to do, but modern computers can do that in a fraction of a second, so Caesar ciphers are not considered a secure method to encrypt electronic communications.

Extra: another way to crack the Caesar cipher is "frequency analysis." Frequency analysis is based on the fact that, in natural English speech and writing, certain letters appear much more frequently than others. For example, the letter "e" appears more often than any other letter, and "z" appears the least often (if you have ever played the board game Scrabble®, you may notice that this determines how many points letters are worth!). So, for example, if you read an entire paragraph and notice that the letter "d" appears more often than any other letter, odds are that it used a Caesar cipher with a shift of 1. This technique will be more accurate for longer blocks of text and very inaccurate for short words or phrases, since there are plenty of words that do not contain the letter "e" at all. Can you have a friend write an entire paragraph with a Caesar cipher and then try to crack it using frequency analysis?

Extra: if you plan to use the Caesar cipher for regular communication, one risk is that eventually someone will discover your key. You can help prevent this by changing the key, for example using a new one every week. This is a similar concept to periodically changing your computer passwords.

Extra: the Caesar cipher is just one type of substitution cipher. Look up some other types of substitution ciphers and try them out. Are they harder or easier to use and crack?

## Observations and Results

Once you and your friend both understand how to use a Caesar cipher, it should be relatively easy to send encrypted communications to each other. This can be a fun way to pass secret messages back and forth between friends. However, while the Caesar cipher provides a great introduction to cryptography, as discussed above, in the era of modern computers it is no longer a secure way to send encrypted communications – so please don't try to use it for any personal information online (like your address or bank account information)!

### Careers

Career Profile
Cryptographers, also called cryptologists and cryptanalysts, develop the encryption algorithms that keep our modern online transactions, like emails and credit card purchases, safe from prying eyes. Even if information or a message is stolen, as long as it is encrypted, the person who stole it cannot read it! Cryptographers also work to test and break these algorithms, to check them for weaknesses and vulnerabilities. They even analyze and decipher codes used by terrorists and foreign… Read more
Career Profile
Have you ever seen a story on the news about how a company or government agency was "hacked" and people's personal information, like names, addresses, or credit card numbers, was stolen? It is an information security analyst's job to prevent that from happening. Organizations hire information security analysts to analyze possible threats against their computer systems, which can range from malicious hackers trying to steal data to careless employees who accidentally forget to log out of a… Read more

## Reviews

|
Science Buddies |