To begin, let’s make sure we understand the difference between a cipher and a code. Actually, I dare you to get up and go ask someone the same question right now. While you do that I’ll wait here and admire this Lorenz cipher machine...
Did they stumble around for an answer? For most people, it’s as if you asked them what the difference is between mix and blend. Tough question. Luckily, we have a video on Morse Code which introduces the idea of a codebook—check it out! In the video we see how telegraph operators could save time by mapping entire sentences to shorter words.
Here, the word accountant is code for "Come at once. Do not delay." A code is a mapping from some meaningful unit—such as a word, sentence, or phrase— into something else—usually a shorter group of symbols. For example, we could make up a code where the word apple is written as 67. Generally codes are ways of saving time, and when sending messages around the world, time is money.
A codebook is simply a list of these mappings. Codebooks have been around ever since we began writing. Just remember,a code requires a codebook.
Okay, so what about ciphers?
Most importantly, ciphers do not involve meaning. Instead they are mechanical operations, known as algorithms, that are performed on individual or small chunks of letters. For example, in the Caesar Cipher we saw how each letter in the alphabet was mapped to a different letter: A=D, B=E, and C=F, according to a specific shift, in this case three. This kind of cipher is known as a shift cipher. Review how this works using the interactive tool below:
In this case, we don’t need a codebook. Instead, we follow a series of instructions—shift each letter by a certain number—also known as an algorithm. The algorithm requires one piece of shared information known as a key. I n the above example the key is 3. This shared key is required for two parties to encrypt, HELLO = KHOOR, and decrypt, KHOOR=HELLO, messages.
So back to our question: What is the difference between codes and ciphers? Codes generally operate on semantics, meaning, while ciphers operate on syntax, symbols. A code is stored as a mapping in a codebook, while ciphers transform individual symbols according to an algorithm.
Now, let’s review the mechanics involved in the Caesar Cipher in the next exercise.