## Caesar Cipher

- Lesson

In this lesson, students will investigate the Caesar substitution cipher. Text will be encoded and decoded using inverse operations.

Begin the lesson by posing the question, "What methods have you seen for encoding secret messages?" Student responses may include Morse code, decoder rings from cereal boxes, or taking the letters of the alphabet and assigning a number (A = 1, B = 2, ...) or a symbol (A = ♣, B = ♠, ...) to each of them. Students may indicate that the *ciphertext* (the result after a message has been encoded) is sent to someone else, and the recipient can decode the message only if they know the system that was used. Some students may add that they used similar systems, except that they assigned numbers to each letter of the alphabet in a random way. Students should be encouraged to share their ideas with the class.

Next, have students work with a partner to break a simple coded message, one that uses A = 1, B = 2, C = 3, ..., Z = 26. On the board or overhead projector, display the following ciphertext:

In all likelihood, students will quickly decode this message because of the simplicity of the coding system. However, should some students have difficulty decoding the message, prompt them by asking, "What numbers occur most frequently in the ciphertext?" Ask them to consider what letters occur most frequently. This hint should put them on the path to a correct solution.

After students have decoded the message (or at least part of it), display the decoded message: "Today you will learn about codes." If students did not realize what coding system was used, reveal that A = 1, B = 2, etc.

Point out that this coding system, as well as the ones that students likely suggested at the beginning of the lesson, are fairly easy to break; even without knowing the coding system, expert code breakers are able to decipher them in minutes or even seconds. In all likelihood, code breakers would use letter frequency analysis to break this code.

Frequency analysis is the process by which the frequency of a letter in an encoded messages is compared with the frequency of letters in English words. For instance, the letter E occurs most often in English words, so if the letter W occurs most often in ciphertext, then it is likely that E has been replaced by W.

To show students how to use letter analysis to break a code, give them the following coded message:

TFNRIUJ UZV DREP KZDVJ SVWFIV KYVZI UVRKYJ;

KYV MRCZREK EVMVI KRJKV FW UVRKY SLK FETV.

The decoded message, taken from William Shakespeare’s play *Julius Caesar*, is "Cowards die many times before their deaths; the valiant never taste of death but once."

Display the Letter Frequency Overhead, which shows which letters are used most often in English words. Let your students suggest how this information could be used to crack the code. [The letters that occur most frequently in the ciphertext will likely correspond to the letters that occur most frequently in English words.]

By analyzing the ciphertext, students should notice the following:

- The letter V occurs the most times (13) in the ciphertext.
- The letter K occurs the second most times (9) in the ciphertext.
- The letter R occurs the third most times (7) in the ciphertext.
- The first five letters of word just before the semicolon are the same as the letters of the third word from the end: UVRKY.

The most frequently occurring letters in English words are E (13.0%) and T (9.3%). By comparing these percents to the most frequent occurrences in the encoded message, it seems reasonable that E and T might have been replaced by V, K, or R. If the frequencies hold, then E was probably replaced by V, and T was likely replaced by K. Substituting these into the ciphertext reveals that the word just after the semicolon is T_E; this suggests that the middle letter is probably H, giving THE, so H was probably replaced by Y when the message was encoded.

Continuing the same type of reasoning, the next five most common letters on the Letter Frequency Overhead chart are A, I, N, O, and R, all of which are just over 7%. These letters were probably replaced by the letters E, F, I, J, U, Y, and Z, all of which occur four times in the ciphertext. Students can use this information with some logic to begin putting letters in place. Eventually, some words will become obvious, and students can make guesses at the missing letters without using the frequency table. You may wish to guide students as they crack this code and decipher the message.

While cracking this code, students may realize that the ciphertext was created by replacing each letter of plaintext with a letter 17 places ahead in the alphabet. In particular, A was replaced by R, B was replaced by S, C was replaced by T, and so forth. That is, *a shift of 17 units* was used. If students did not notice this, point it out to them.

A *Caesar cipher* is a coding system in which letters are replaced by letters a certain distance ahead in the alphabet. Julius Caesar is thought to have used this method to communicate with officers in the Roman army. When sending a message, Caesar would inform his generals what the shift was, so they would be the only ones who could read the encrypted message.

Armed with this information, the students are ready to proceed to code a message using the Caesar cipher. Pretend that you are Julius Caesar, and your students are your generals. You are conducting a meeting about sending encrypted communications. You have decided to us a shift of 7 units, which allows for the following replacement of letters:

Plaintext: | ||||||||||||||||||||||||||

Ciphertext: |

Distribute the Caesar Shifter Activity Sheet. Students can cut out the circles to make a Caesar Shifter, which can be used for encoding and decoding methods with the Caesar substitution cipher.

For the shift of 7 described above, students would use the Caesar shifter by rotating the letter A on the smaller circle so that it appears under the H on the larger circle. The number 7 above the H on the larger circle indicates that this is a shift of 7 units.

On the chalkboard or overhead projector, write the following message:

ROME IS THE GREATEST EMPIRE.

Allow students to encrypt this message using the Caesar shifter. When encoded, the message will read:

YVTL PZ AOL NYLHALZA LTWPYL.

Next, provide the ciphertext message below ("Rome was not built in a day.") for the generals to decode.

YVTL DHZ UVA IBPSA PU H KHF.

Have students decode this message using either the Caesar Shifter or frequency analysis. (You might even want to divide the class into two groups, with each group using one of these methods, to see which method is faster.) Although this is a small amount of text, the you can find free online tools that can be used to tally letter frequencies (perform a quick Internet search).

Students may also use logic when decoding the message. Some students may notice the one-letter word *h* that appears near the end of the message. Since this letter must represent either *a* or *I* (these are the only two single-letter English words), students can determine the possible shifts and see which one works for the remainder of the message.

Have students use the Codes Tool to verify their results. To replicate a Caesar shift of 7, students will need to enter a Shift Value of 7 and a Stretch Value of 1. (Note that the Codes Tool only works with lowercase letters; if uppercase letters are used, they are not changed when encoded or decoded. For instance, if "rome" is entered into the tool, it will be encoded correctly as "yvtl." However, if "Rome" is entered, it will be encoded incorrectly as "Rvtl," because the uppercase R will remain. This apparent flaw in the tool is actually by design. When encoding a message, it is best to remove all uppercase letters; because they indicate the start of a proper noun or the word *I*, they offer clues to code breakers. Therefore, it is better to use only lowercase letters when encoding a message.)

Now that students are familiar with the Caesar cipher, distribute the Caesar Cipher Activity Sheet.

In pairs, allow students to answer Questions 1-5. For Question 1, allow students to research Julius Caesar on the Internet.

Allow sufficient time for students to complete Questions 1-5, then bring the students back together and review the answers.

[Julius Caesar was the Emperor of Rome. He lived from 100-44 B.C. The Caesar cipher has 25 possible shifts. A shift of 26 or more will simply repeat one of the shifts of 1-25. This was probably sufficient during Caesar’s time, but it is insufficient today because of advanced code breaking methods. Because there are only 25 possible shifts, a person could test each possible shift to determine if an encoded message uses the Caesar Cipher.]

- Computer with Internet connection
- Caesar Cipher Activity Sheet
- Caesar Shifter Activity Sheet
- Letter Frequency Overhead Chart

**Assessments**

- Allow students to encode a message using the Caesar cipher and any shift they choose and give the ciphertext to a classmate. The student receiving the ciphertext should decode the message and be able to tell what shift was used.
- Have students develop their own coding system and exchange with a partner to break their code.

**Extensions**

- Have students use frequency analysis to decode the secret messages in
*The Adventure of the Dancing Men*, a Sherlock Holmes mystery by Sir Arthur Conan Doyle.

Codes used in*The Adventure of the Dancing Men* - Working with the English or Language Arts teacher, you may want to have students read the entire story.
*The Adventures of the Dancing Men*, by Sir Arthur Conan Doyle

**Question for Students**

Explain why the number of total shifts possible for the Caesar cipher is a weakness for this coding system.

[Because there are only 25 possible shifts, a code breaker could decode the message by trying each of them. A coding system with more possibilities would be more difficult to crack.]

**Teacher Reflection**

- Were students able to use the letter frequencies to decode the messages? Did they have sufficient knowledge of ratios to be able to apply this concept? Explain.
- What connections did students make between math and its applications to the real world?
- Were students focused and on task throughout the lesson? If not, what improvements could be made the next time this lesson is used?
- How did students demonstrate that they were actively learning?

### Vigenere Cipher

### Learning Objectives

Students will:

- Encode a message using the Caesar cipher.
- Use an inverse process to decode a message.

### Common Core State Standards – Practice

- CCSS.Math.Practice.MP2

Reason abstractly and quantitatively.