This activity is brought to you by the Department of Computer Science at the University of Auckland.


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.

Password key

Your task: enter the correct password below.

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 on guessing the password.
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"?
Choose an answer below...

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".

Code Wheel Example

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”.

Next challenge: encipher a word using the code wheel.

Enciphering with a code wheel

Code Wheel Example

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


Deciphering with a code wheel

Code Wheel Example

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.


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.


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.


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”.


One last task

As a final challenge, try to decipher the word below using the two wheels. In this case the word is quite a lot harder to find.



You have now completed all the exercises.

You have learned a little bit about the problem of secure communication, illustrated by some ancient ciphers. An important concept is the "key" to a cipher. The sender uses the key to transform the message into a ciphertext. The ciphertext can be sent over an insecure channel (e.g., email or text message). A receiver who knows the key can unscramble the ciphertext and learn the message that was sent. An important requirement for security is that there must be a large number of possible keys, to make the attackers job difficult. However, having a large number of keys does not necessarily guarantee security. For example, the ciphers explored in this activity can be broken more efficiently using letter frequencies of the English language, if you want to learn more about this you can find a lot more information online.