Imagine you've got an important message to send that you need to keep private. Maybe it's a love note meant for the object of your affection; maybe it's a classified communiqué meant only for your handler. Whatever the case, if you're going to keep the message secret, you're going to need a way to encrypt it so that nobody, other than the intended receiver, can read it. So how might you encrypt the message?
One approach is to use what's called a "shift cipher." This involves taking your message and shifting each letter in that message by some fixed amount. For example, suppose your message said "I HAVE A SECRET." Shifting by 1 would move every letter one place down in the alphabet: A would move to B, B would move to C, and your message would convert to "J IBWF B TFDSFU." Shifting by 2 would move A to C, B to D, and your message would become "K JCXG C UGETGV."
Since there are 26 letters in the alphabet, there are 26 possible shift ciphers. Here's a table of how each letter transforms using the Shift 2 cipher from above:
|Original Letter||Shifted Letter|
If tables aren't really your thing, you can also graph these ciphers, by replacing letters with numbers. If, as in the table above, we let 0 stand for A, 1 stand for B, and so on, then the shift 2 cipher takes every number and adds 2 to it. (Note: we need to be a little careful towards the end of the alphabet. Since there are only 26 letters, after X gets sent to Z, Y should get sent to letter A. Mathematically, this means we're adding two to each number, but if the sum is greater than 26, we subtract 26.) The graph of the shift 2 cipher would then look like this:
Of course, there are plenty of other ways to replace letters with other letters aside from using shift ciphers. Here are several other graphs that you could use to encode messages:
These graphs tell us how to replace letters in any message. For example, in the black graph, the first point is (0, 12). This tells us that A (the 0th letter) gets sent to M (the 12th letter). Similarly, in the red graph A gets sent to A since the first point is (0, 0), and in the blue graph A gets sent to B since the first point is (0, 1). Encoding our message from before, I HAVE A SECRET becomes Q JMDO M IOABOP with the black graph, I LAVK A SKGXKP with the red graph, and N YBAR B NRFERY with the blue graph.
This may seem all well and good, but what happens if you have the graph and the encrypted message and are trying to decrypt it? With the first two graphs, you'll have no difficulty. For example, if you have the black graph and the first encrypted message, you know the first encrypted letter is Q. Q corresponds to number 16, and the point on the graph with a y-coordinate of 16 is (8, 16), meaning that the original letter is #8, which is I. If you continue in this way, you'll be able to decrypt the message.
The same approach works for the red graph. But what about blue? In this case, the first encrypted letter is N, which corresponds to number 13. But with this cipher, two letters get sent to N: the letter I (represented by (8, 13)) and the letter S (represented by (18, 13))! In fact, nearly every letter in the encoded message could have come from one of two letters.
This happens with the blue graph because there are many pairs of points with the same y-coordinate. Since mapping many letters to the same letter makes decryption difficult, this is probably something we want to avoid. In other words, no two points on the graph should have the same y-coordinate. In other other words, the graph of a useful cipher should pass a horizontal line test!
If this sounds like familiar language from the study of inverse functions, that's not a coincidence. After all, encryption should be an invertible process, otherwise there would be no way to undo it and recover the original message.
Teachers: want to talk about secret messages with your students? Then check out our new lesson, Decoder Ring.