Secret Cipher

This applet lets you write a message and encode it so no one else can read it without your secret key. This substitution cipher is based on one proposed by mathematician Blaise de Vigenere in the 16th century (no he didn't have a computer). It's considerably harder to break than the simple substitution cipher in Secret II. See the lecture to find out how it works.

What You Do
First, decide on a key. This can be any word you choose. The program will use this word to scramble (encode) and unscramble (decode) your message. Only the key that was used to encode a message can decode it. Enter it where you see the "ABC".
Next, Enter a message you want to scramble (where "AZ az" is now).
Click the "Encode" button to scramble your message.
Click the "Decode button to unscramble your message.

You can do some odd things and still get your message back. If you click the Encode button 3 times, clicking the Decode button 3 times will reveal your message. You can click Decode first, then Encode, it really doesn't matter. You could encode with one key word, then use another. As long as you just reverse whatever you did to encode the message, you can get it back. You can decode a message by hand if you know the Key word.

You may want to print out your encrypted message or send it in an email. Unfortunately, web browsers don't really know much about the applets running in their windows, so they usually just print a blank spot where an applet is. You'll need to copy the message and paste it into an email or word processor. You will probably have to use the keyboard instead of the Edit menu. Select the text, then Control C for copy and Control V for paste. (You Mac folks use Command C and Command V.) Send someone a secret message and the key and point them back here to decode it!

The Lecture
Here's how it works. Let's treat letters like they are numbers. In this case, I've used 52 letter-numbers:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 
a b c d e f g h i j k l m n o p q r s t u v w x y z
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

In the example above (when you first loaded this page), our key is 'ABC'. If we take the first letter 'A' and add it to the first letter of the message, also 'A', we get 1 + 1 = 2. The value of 2 is 'B'. Do the same for the next letter. 'B'(2) in the key + 'Z'(26) in the message = 28 ('b'). The 'C' matches with, wait a minute, it's a space. I've written the program so it only modifies letters so poor 'C' doesn't get to do anything yet. Since 'C' is the last letter of our key, we go back to the first letter - 'A'(1) to match up with 'a'(27) to give 28 ('b'). Finally, we have 'B'(2) + 'z'(52) = 54. Since we don't have a 54, let's circle around to the beginning by subtracting 52. That gives us 2 ('B'). Here's a summary if you want to know:
key: A (1) B (2) C start at first letter A (1) B (2)
+ message A (1) Z (26) 'space' a (27) z (52)
encoded message B (2) b (28) 'space' b (28) B (54-52)

 


     Home      Sitemap      Contact           Copyright 2009 by Douglas Dodd, Ph.D., all rights reserved