Wiki Menu


Home
Syllabus
Schedule
Screen Copy
Grader
Pre-Test
Billiards
Induction
Deduction
3 Ladies
3 Prisoners
Arithmetic
Pyramid
Geometric
Keyboard
Binary
8-Bit Adder
Squares
Cubes
Ring Game
Fibonacci
Phyllotaxis
Nim
Staircase
Counting
Flowers
Permutations
Duplications
Coin Flip
Combinations
Pascal's Tree
Texas Poker
Dice Rolls
Candychines
Lottery
Binomial ESP
More Dice
Monty Hall
Birthdays
BlackJack
Slot Machines
Ciphers
Today's Quote
Bell Curve
M&M Sampling
Worm Holes
Doodles
World Tour
CSG
Polys
Fractals
Chaos Game
Eggbrot

3 Codes


CRYPTOLOGY
SECRET CODES



Here is a picture of my 1949 Captain Midnight Key-O-Matic Code-O-Graph Decoder purchased for 25¢ and a jar of Ovaltine. At the end of each Captain Midnight radio episode, I would listen intently for that week's secret code–something like "QEVAX ZBER BINYGVAR", which I translated slowly, but devotedly. Consistently, the message was a variation of "DRINK MORE OVALTINE". Perhaps you have seen this scene in a movie somewhere: A Christmas Story? My version of the movie was a little different—I never got the BB gun.

Cryptology is the study of secret codes.
In today's project we will explore three of them: Caesar, Vigenere, and XOR.

Click here for a Codes Demo.
    First some definitions:
  • A code is a secret message.
  • To encrypt a message is to encode it.
  • To decrypt a message is to decode it.
  • A cipher is a method for writing secret codes.
  • To encipher is to encrypt or encode.
  • To decipher is to decrypt or decode.
  • encode = encrypt = encipher = code
  • decode = decrypt = decipher = crack
QEVAX ZBER BINYGVAR encrypts (i.e encodes) DRINK MORE OVALTINE.
DRINK MORE OVALTINE decrypts (i.e decodes) QEVAX ZBER BINYGVAR.


1. The Caesar Code Assignment



Julius Caesar wrote his journals using what is now known as the Caesar Code. Press the [ENTER] key inside the Original Message box and the encoded message appears in the Encrypted Message box. Type DRINK MORE OVALTINE in the Original Message box, and QEVAX ZBER BINYGVAR appears in the Encrypted Message box. Notice that there is also a «Shift» box containing a number. This number tells the Caesar encoder how far to shift a character ahead in the alphabet. If the number is 13, the letter A is shifted ahead 13 positions in the alphabet to to the letter N. M is shifted to Z. N is shifted around and rotated back to A.

Now place the encrytped message QEVAX ZBER BINYGVAR in the Original Message box. (You can drag your mouse to hilight, copy, and paste text from one box to another.) Press the [ENTER] key, and the decrypted text DRINK MORE OVALTINE appears in the encrypted box. Try this with various messages. Change the shift number each time. What number must you shift the code to arrive back at the original message? Notice that the encrypting shift number when added to the decrypting shift number always equals 26.

In the Caesar code, A=0, B=1, C=2, ..., Z=25. After Z, comes A again, just as on our clock, after 12 comes 1. When we compute time, we use what is called a modulo 12 system. For our purposes, modulo means circular or round. We call the Caesar code a modulo 26 system, because the alphabet has 26 letters, and so the corresponding numbers cannot go higher than 25. If you shift a letter 26 places, it goes right back to where it came from. Shifting a letter 27 places, is the same as shifting it 1 place. Shifting A ahead 27 places, shifts it to B.

When you shift each letter of the alphabet 13 places, the last 13 letters take the place of the first 13 letters. NOPQRSTUVWXYZ becomes ABCDEFGHIJKLM. Shift DRINK MORE OVALTINE only 9 letters by changing the number in the Shift box. This time all the letters will shift ahead 9 places: ABCDEFGHIJKLMNOPQ becomes JKLMNOPQRSTUVWXYZ. Whereas, the last 9 letters RSTUVWXYZ in the alphabet will rotate around to ABCDEFGHI. Since the difference between 26 and 9 is 17, shifting JKLMNOPQRSTUVWXYZABCDEFGHI by 17 more places puts them back where they started at ABCDEFGHIJKLMNOPQRSTUVWXYZ.

When you shift each letter of the alphabet 13 places, and then shift the results 13 more, you will arrive back at your original message. Likewise, when you shift each letter of the alphabet 16 places, and then shift the results 10 more, you will arrive back at your original message. Try it.

V E N I, V I D I, V I C I ORIGINAL MESSAGE 21 04 13 08, 21 08 03 08, 21 08 02 08 POSITIONS 16 16 16 16 16 16 16 16 16 16 16 16 ADD 16 ________________________________________ 37 20 29 24 37 24 19 24 37 24 18 24 SUM 11 20 03 24 11 24 19 24 11 24 18 24 MOD 26 POSITIONS L U D Y, L Y T Y, L Y S Y! SECRET MESSAGE

You can use this modulo rotation idea to crack any Caesar code. By trial and error, you can continue shifting an encrytped message until you arrive back at the original. Always subtract 26 if position is greater than 25.

L U D Y, L Y T Y, L Y S Y! ENCODED MESSAGE 11 20 03 24 11 24 19 24 11 24 18 24 10 10 10 10 10 10 10 10 10 10 10 10 ADD 10 ________________________________________ 21 30 13 34 21 34 29 34 21 34 28 34 SUM 21 04 13 08, 21 08 03 08, 21 08 02 08 MOD 26 V E N I, V I D I, V I C I DECODED MESSAGE

For 1 point, encrypt your favorite phrase the Caesar way and post it on the wiki. What is it that you hear yourself saying over and over? Is it something like "DUDE", "WAHZHAPNIN?", "COOLNESS", or something more profound like "KOSMIK", "EXISTENTIAL", "POST-DESTRUCTIVE"? Encode your phrase by shifting it by any number of places between 1 and 25. Shifting 0 or 26 places, or any multiple of 26, does not change anything. Do not reveal on the wiki how many places you shifted your phrase, but do tell us you are using the Caesar code. Keep your phrase brief to about the same length as Wheel of Fortune phrases (that is, about 3 or 4 words.) It is up to your discretion to delete expletives.

For 1 more point, decrypt someone else's Caesar phrase that has not previously been decrypted, and post it as a wiki comment. Tell us whose phrase you decrypted, and how much it was shifted. Use trial and error. It should require no more than 25 trials. However if you notice 3 letter words, they just might be "THE" or "AND". You may shorten your search, by noticing other common letter combinations also. In English, the letter E occurs more often than any other. Here is an ordered list of letter frequencies in English:
E T A O I N S R H L D C U M F P G W Y B V K X J Q Z .
Just hope that no one's favorite phrase is in Spanish.
"Ea, Caramba!"


2. The Vigenere Code Assignment



The Vigenere code was developed in the 16th century by Blaise de Vigenere, a French diplomat. For centuries, it was used by the Vatican and other governments for secret diplomatic communications. A keyword is required to encode your original message, and the same keyword is necessary when someone else decodes the encryption. The position of each character in the keyword is added to the position of each character in the message, repeating the keyword as many times as necessary, and ignoring characters that are not letters, like so:

VENI, VIDI, VICI! 21 04 13 08, 21 08 03 08, 21 08 02 08 ORIGINAL MESSAGE CAESARCAESARCAESA 02 00 04 18 02 00 04 18 02 00 04 18 ADD C A E S A R key ________________ ________________________________________ 23 04 17 26 23 08 07 26 23 08 06 26 SUM XERA, XIHA, XIGA! 23 04 17 00 23 08 07 00 23 08 06 00 MOD 26 ENCRYPTION

To decrypt the secret code, we must subtract the positions of the secret keyword from the encryption, borrowing 26 if necessary, like so:

XERA, XIHA, XIGA! 23 04 17 00 23 08 07 00 23 08 06 00 SECRET CODE CAESARCAESARCAESA 02 00 04 18 02 00 04 18 02 00 04 18 SUBTRACT C A E S A R key ________________ ________________________________________ VENI, VIDI, VICI! 21 04 13 08, 21 08 03 08, 21 08 02 08 ORIGINAL MESSAGE

If the keyword is as long as the message, the Vigenere Code becomes the Vernam Code—the most secure, unbreakable code ever devised. Nevertheless, the British during World War II, using the first electronic computers, cracked the German version of the Vernam Code, called the Lorenz System, and eventually won the war. How they did it can be seen in the 2002 movie titled Enigma, the British name for the Lorenz System. You can make your own Enigma machine with a paper printout from mckoss.com/Crypto/Enigma.htm.

For 1 point, find something your Alphasets celebrity said—perhaps in a movie, a book, or on TV. Encrypt this quote using the Vigenere applet. Use the celebrity's LAST name as the keyword. Post the quote on the wiki. Do not reveal who said it.

For 1 more point, decrypt someone else's Vigenere quote that has not previously been decrypted. You will need to research the Alphasets page to match celebrity with a fellow student. Assume that the celebrity's last name is the keyword that decodes the quote. Post the decrypted quote as a wiki comment. Tell us the student who posted the quote, and the celebrity who said it.



3. The XOR Code Assignment



The XOR Code is a binary code from the computer age. Like the Vigenere code, the XOR, or Exclusive-Or, code uses a keyword. To encrypt a message, each letter in the message, and each letter in the keyword, is first converted into its binary equivalent. Then each letter in the message is XORed with each character in the keyword, like so:

VENI, VIDI, VICI! 21 04 13 08, 21 08 03 08, 21 08 02 08 ORIGINAL MESSAGE CAESARCAESARCAESA 02 00 04 18 02 00 04 18 02 00 04 18 C A E S A R key ________________ ________________________________________ XEJ[, XIH[, XIG[! 23 04 09 26 23 08 07 26 23 08 06 26 XOR ENCRYPTION

Notice that the encryption results are close to the Vigenere encryption. However, there is no modular 26 with the XOR code. The 26 on the encryption line refers to the next ASCII character after Z—the left bracket [. For the XOR code to work, there must be a power of 2 number of characters. Since 32 is the next power of 2 after 26, 6 more characters are needed for a XOR code that encrypts the 26 uppercase letters. These extra characters are [ \ ] ^ _ `; these are the six ASCII characters that follow Z... XOR codes that include lowercase letters would need 64 characters: 26+6+26+6=64.

Notice that in the Vigenere code, adding N and E resulted in an R. Look at the binary code for these letters:

1 1 CARRY DIGIT N = 0 0 0 0 1 1 0 1 = 13 ORIGINAL CHARACTER E = 0 0 0 0 0 1 0 0 = 04 ADD KEY CHARACTER _______________________ R = 0 0 0 1 0 0 0 1 = 17 SUM ENCRYPTION

The sum includes the carry digits.
XORing letters N and E, however, results in a J. Here is why:

N = 0 0 0 0 1 1 0 1 = 13 ORIGINAL CHARACTER E = 0 0 0 0 0 1 0 0 = 04 KEY CHARACTER _______________________ J = 0 0 0 0 1 0 0 1 = 09 XOR ENCRYPTION

The XOR excludes all carry digits. These methods should remind you of the way Looloolos add two numbers, with and without the carry.

In the XOR code, XORing the encryption with the keyword, results in the original message! This means that all you need to decrypt a XOR cipher is the keyword.

XEJ[, XIH[, XIG[! 23 04 09 26 23 08 07 26 23 08 06 26 XOR ENCRYPTION CAESARCAESARCAESA 02 00 04 18 02 00 04 18 02 00 04 18 C A E S A R key ________________ ________________________________________ VENI, VIDI, VICI! 21 04 13 08, 21 08 03 08, 21 08 02 08 ORIGINAL MESSAGE

Try it. For 1 point, find a quote from the movie, song, or book that you chose for your ASCII code assignment. Let the keyword be the LAST name of your favorite actor/author/artist you chose for the ASCII assignment. Encrypt this quote using the XOR applet. Post the quote on the wiki. Do not reveal who said it.

For 2 more points, decrypt someone else's XOR quote that has not previously been decrypted. You will need to research the ASCII page to match actor, singer, or author with a fellow student. Assume that the actor, singer, or author last name is the keyword that decodes the quote. Post the decrypted quote as a wiki comment. Tell us the student who posted the quote, and the actor, singer, or author who said it.

Read more about secret codes in the sci-fi novel by Neal Stephenson titled Cryptonomicon.

Comment on this Page
Last Modified 8/24/08 4:21 PM

Hide Tools