When we think of codes, we usually think of spies, espionage and intrigue. Although codes have been used extensively by various governments, codes are used in many other ways as well, not just in spy rings.
Codes are all around us. One of the most famous codes is the Morse Code, used for many years in telegraphy. Invented by Samuel Morse, his code allowed letters of the alphabet to be sent long distances. Short electrical signals were the "dots," and long electrical signals were the "dashes."
Another code that you see almost every day is a bar code which can be found on almost everything you buy at the store. These black bars and the spaces between them can be read by optical scanners, which then read the code, feed the information into the computer, match that code to the code on file, then register the correct price on the cash register.
In written messages, a code normally substitutes words with other words. For instance, a military leader might use a code where "enemy" would be written as "flour barrels." He would use a codebook to look up each word he needed to use in his message. When his soldiers received the message, they would use a matching codebook to look up the real meanings. Codes like this have the weakness of falling apart completely – and permanently – if the enemy can get hold of just one of your codebooks.
On the other hand, a cipher normally relies on a key, which is the method used to decipher, or figure out, the message. Ciphers usually have two advantages: they are generally harder to crack than a code, and they are typically less cumbersome to use. For instance, look at the following (very simple) cipher and see if you can decipher it before you read any further:
3-15-4-5-19 1-14-4 3-9-16-8-5-18-19 8-1-22-5 16-21-26-26-12-5-4 16-5-15-16-12-5 5-15-18 20-8-15-21-19-1-14-4-19 15-6 25-5-1-18-19. 2-21-20 20-8-5-25 1-12-12 8-1-22-5 20-8-5 19-1-13-5 16-21-18-16-15-19-5: 20-15 16-18-15-20-5-3-20 9-13-16-15-18-20-1-14-20 9-14-6-15-18-13-1-20-9-15-14.
As you've probably noticed, this cipher works by substituting numbers for letters. 1 represents A, 2 represents B, and so on, with a dash between each letter so the numbers can be read properly. The key to this cipher is the numbering sequence. You could change the cipher by using 1 for Z and 26 for A. Either way, someone would need to know the key to read the message.
Julius Caesar used a cipher in which each letter was represented by the letter three places to its right in the alphabet, "wrapping around" to the beginning for the letters X, Y and Z. With this cipher, "time for lunch" would be written as "wlph iru oxqfk." The key to this cipher is the "letter shift." You could easily use the same principle with a letter shift of five or six positions, or by changing the direction of the shift.
Ciphers can be cracked (figured out without the key) in several different ways. Frequency analysis is one way. By knowing how often certain letters are normally used, a cryptographer (someone who studies codes and ciphers) can sometimes figure out which symbols in a message represent which letters. For example, E is the most common letter in the English language. So, if you wrote a cipher where each letter was represented by a different letter, and if you chose P to represent the letter E, a cryptographer could probably figure out that P meant E just by realizing there were more P's than any other letter in your message. Frequency analysis works best on longer messages since correct guesses are easier to identify.
Now that you know a little about codes and ciphers, let's try to make our own. Say we'd like to send the following message:
I want pizza for supper.
We'll start with a simple substitution cipher, where A stands for Z and vice-versa, B stands for Y, C for X, and so on. Therefore, our message will now read like this:
R dzmg kraaz uli hfkkvi.
That's pretty scrambled. But someone who knows what they're doing can break that pretty easily, especially if our message was longer. So, let's make it a little more complicated by reversing the whole thing:
.ivkkfh ilu zaark gmzd R
Not bad, but anyone who knows the basics of English grammar will be able to figure out that we reversed our message just by noticing that we start with a period and end with a capital letter. So, let's eliminate punctuation and capitals:
ivkkfh ilu zaark gmzd r
We're getting there, but we've left a clue that could help someone break the message. Since "A" and "I" are the only letters that can be used as entire words, the letter "r" sitting all by itself there at the end must actually represent one of those two letters. While not particularly useful on a message this short, a longer message with more "r's" in it would be easy to decipher with this clue. So let's run everything together into one long string:
There--that's not world-class, but it should stump your friends for awhile! To decipher your encoded message, all you have to do is reverse it and substitute the encoded letters for the correct ones. This will give you "iwantpizzaforsupper," which is easily recognized.
Now that you know a little bit about codes and ciphers, see if you can come up with your own! Just remember that your messages should be as easy as possible to decipher for someone who knows the key; in other words, don't make it so complicated that it takes a long time to read your own messages!
Modern ciphers use mathematical formulas called algorithms to encrypt messages. Most of these ciphers are impossible to crack (or even read) without a special computer program, and computers must be used to encrypt the message. These types of ciphers are very difficult to crack even if someone knows exactly how they work, as long as the key is kept a secret. This is a little hard to explain, so let's use a little project as an example. I'll give the instructions first, then get back to the computerized ciphers afterwards.
An early encoding method used a device called a scytale (rhymes with "Italy"), which you can easily make yourself. You'll need two or three rods or dowels of different diameters, a pen, and some long strips of paper about half an inch wide. Choose a dowel and start wrapping the paper around it as shown in the diagram. You may want to tape the ends in place.
Now, write a message on the paper, lengthwise along the dowel, one letter for each turn of the paper. When you get to the right-hand end of the dowel, go back to the left end and start a new row of letters. When you're finished writing your message, unwind the paper and you'll have a random-looking sequence of letters that won't make any sense at all. The message can only be read by wrapping the paper around the right size of dowel. Take turns writing scytale messages with different sizes of dowels and decoding them!
Now, think about a computerized cipher again. Someone can know exactly how the cipher works, yet still be unable to crack a message because they don't have the key. A scytale works the same way, since an enemy could know exactly how to read the message (wrap the paper around a rod), but without the key (a rod of the correct diameter), he still could not read the message. Modern computerized ciphers work on more or less the same principle.
I hope you've enjoyed this brief foray into the exciting world of codes and ciphers! tnU nli txe mit h,e ppa icy ehp nir !g
Matthew Lewis, a homeschool graduate, is the web developer, and occasional columnist, for Home School Enrichment Magazine. Matthew is a self-described computer geek who enjoys doing things during his free time which he says would sound much too boring to be mentioned here.
This article was originally published in the Sep/Oct '07 issue of Home School Enrichment Magazine. For more details, visit http://HomeSchoolEnrichment.com