# Encryption

We all know that keys can be used to unlock doors, but did you know that ‘letter’ keys can help to both protect and unlock secret messages (otherwise known as ciphertext)? This activity will teach you more about encryption and how it works!

__________________________________

## Key matching

Drag a key onto the padlock to try it.

The password is a three digit number and uses only the digits "1" and "2".

Try all the possibilities until you find the right one!

# Congratulations!

There were 8 possible passwords you could have tried:

• 111
• 112
• 121
• 122
• 211
• 212
• 221
• 222

How many possible passwords would there be if the password was a 4 digit number instead, still using only the digits "1" and "2"?

How many digits would the password need to have so that there were more than one million possible values?

# Code wheel

The Caesar cipher is a method to hide a message. Each letter in the message is changed to a new letter, by "rotating" the alphabet. For example, one might change "A" to "T", "B" to "U", "C" to "V" and so on.

The resulting "ciphertext" can then be transmitted and an attacker won't be able to read it. The process is called "enciphering". This method was used by the ancient Romans. The "key" is the letter that "A" gets transformed to. So the process of changing "A" to "T" is described by saying "the key is T".

A handy tool to help you encipher and decipher is a code wheel (pictured here). The outer wheel represents the letters in the message and the inner wheel is the letters in the ciphertext. We can rotate the inner wheel according to the value of the key that is known to both the sender and receiver of the transmission. In the picture, the key is "T". One can read that "M" is enciphered to "F" and that "J" is deciphered to "Q". So "HI" is enciphered to "AB" and "RXL" is deciphered to "YES”.

# Enciphering with a code wheel

Use the code wheel to encipher the word below. When enciphering, work from the outer wheel inward.

HELLO

# Deciphering with a code wheel

While it's necessary to work from the outer to inner wheel when enciphering, when deciphering you work from the inner to the outer wheel.

Use the code wheel to decipher the following word.

VKTVD

# Deciphering with a code wheel

## (that spins!)

There are 26 possible positions of the code wheel (in other words, 26 possible keys). Hence the Caesar cipher is not secure. It can be broken by trying all values of the code wheel. You can even do this more efficiently by trying common letters of the alphabet first.

Below is a code wheel. You can spin the inner wheel. Try to decipher the given word. Since you don't know the key you will have to try several different positions. A first guess might be that the original message starts with the letter "T". To check this set the wheel so that the "X" on the inner wheel is beside the "T" on the outer wheel. You can then quickly check that the message would have been "TMOWQD", which is nonsense. So that is not the right key.

When you think you have deciphered the word, enter your answer below.

XQSAUH

# Vigenere cipher

Now you understand the code wheel idea, we can try to get a more secure system. As we have explained, there are only 26 keys for the Caesar cipher, so it is not secure. The Vigenere cipher is a way to increase the number of keys and so make the attacker's job more difficult.

First, let us use two code wheels. The odd numbered letters (first, third, fifth, etc) are enciphered using the setting of the first wheel, while the even numbered letters are enciphered using the second wheel.

There are now 2626 = 676 possible keys. So the system is harder to break.*

Encipher the following word using the key settings "X" and "C" on the two wheels.

STRONGER

This example shows that the search for a good key can be improved by using common combinations of letters.

# Deciphering a Vigenere cipher

Now decipher the following text. You will need to try and find out the key for each wheel. As a hint, use the fact that somewhere in the message is the pair of letters "TH”.

CUJNUX