This page provides supplemental information for the book, The Cryptic Case of the Coded Fair by Barbara Tinker, Robert Tinker and Pendred Noyce. For more information on the book, or to order additional copies, please see this link.
Before you begin the, make sure you download a free copy of Netlogo, from Northwestern University’s website. Please follow this link to do so.
Then once you are done with obtaining and installing Netlogo, you should download the following two programs, designed just for ‘The Coded Fair book (please right click, and ‘Save As’ to a destination of your choosing; you can also rename the files and be sure to open them using File>Open in Netlogo):
“Animated Grille” & “Vinegar Table” Information can be found below:
The program “General.encoder.decoder” demonstrates all the codes in the book, “The Cryptic Case of the Coded Fair.” You can use it to encode your own messages in a way that even the U.S. spy agencies might not be able to read. You can use it with email to send secure messages to anyone that can use this program.
How to Use the Program
Here is a snapshot of the display.
You can enter any message into the box on the left called “Plaintext,” pick any combination of five encoding schemes in the center, and see the resulting coded message on the right box called “Cyphertext.” On the far right, the frequency distribution of letters in the coded message is shown. You can also decode any message you enter into the Cyphertext.
All you have to do to use the program to encode a message is to enter a message in the plaintext box and press the button under the box, labeled “Encode Plaintext.” Almost instantly, the encoded message appears in the Cyphertext box along with the frequency distribution of letters in that box. The “Time required” box tells you how long the computer required to encode your message. In the illustration you can see that it took only 0.023 seconds (23-thousanths of a second) to encode 363 characters using the Cardano Grille.
To enter a message, click on the “change” button in the upper right of the box and then enter your message in the box that pops up. Or you can click on the “Display a test message” button to enter pre-loaded messages, some of which are short and others that are long. If you want to repeat the last test message click on “Repeat last message.” If you want to create a longer message repeatedly click “Append a message.”
To decode a message, enter it in the “Cybertext” box and click on the button under that box called “Decode Cyphertext.” The result appears in the Plaintext box. To test that everything is working, you can enter a plaintext message on the left, encode it and then decode it. If you don’t change the rules, the decoded message should be essentially the same as the one you started with. It will not have punctuation and capitals and might have some extra junk added to its end.
The five encoding rules can be activated by clicking the green buttons to the “On” position for each of the five rules. Any combination of these five rules can be used together.
Shift. If you turn on “Shift?” the program uses the Caesar shift. The amount of the shift can be entered in the box “Shift-amount.” The basic Caesar shift uses a shift of -3. The book also mentions a shift of +7.
Grille. If you turn on “Grille?” the 6×6 Caradano Grille is used to encode the plaintext. There are many possible Grilles that can be specified in the “Holes” box. The way the grille is specified is tricky and will be explained later.
Virgenére. By turing on the Virgenére? button, the Virgenére coding scheme is used along with the keyword in the box called “Key.” You can enter any key that you want.
Super-Enigma. This uses one of the super codes invented by the GAS team. It creates a new encoding alphabet for each letter. The first four characters in “Master-key” sets these alphabets.
Super-Cardano. Turning this on uses the other super code invented by the GAS team using the last four characters in the box called “Master-key.” This code completely mixes up the order of the characters in the message.
The decode button will accurately decode any message made with any combination of these codes. The one slight exception is that the Cardano Grille works on groups of 36 letters and if the plaintext does not contain a multiple of 36 letters, the software adds random nulls at the end of the plaintext message to make its length a multiple of 36.
The encoder uses only the 26 letters in the English alphabet. Following Caesar’s rule, the plaintext is shown in lowercase and the encoded message is shown in uppercase. All uppercase letters in the plaintext are converted to lowercase. All numerals and the percent symbol are spelled out, so “3” becomes “three.” Spaces, punctuation, and all other symbols are eliminated. So, “Enter: #23%!!” becomes “entertwothreepercent.” This makes the decoded message harder to read, which is the whole point.
The Super Enigma Scrambler and the Super Cardano Switcher both use the Master-key. You can enter and eight lowercase and uppercase letters, numerals, and characters in the “Master-key” box. There are about 4,700 trillion different possible four-character master keys. Good luck reading the message if you forget the key.
Making Your Own Grille
The default Cardano Grille that the program uses is the one described in the book. You can make your own, but it must be valid. There are over a quarter-million different valid 6×6 Cardano Grilles, but there are over 92 million invalid ones. If you don’t use a valid Grille, the program will not be able to decode properly.
The following illustration will help you create your own valid Grilles. As you can see, there are four squares marked with A, four marked with B, and so on up to the four I letters in the center. All the boxes with the same letter are equivalent when the Grille is rotated, so you can only use one of each. The illustration shows one valid Grille, where the yellow squares will be holes in the Grille. The cells also each contain a unique number running from zero in the upper left to 35 in the lower right.
In the illustration, the A in cell 5 has been selected, the B in cell 34, the C in cell 2, and so on to the I in cell 15. To tell the program to use this grille, simply enter the numbers in the cells that you select. In the illustration, these would be 2, 5, 7, 15, 23, 26, 27, 31, 34. Be sure to separate the numbers with commas and that there are nine numbers, when you enter them into the box called “Holes.”
If you do not create a valid Cardano Grille this way, your decoded message will contain stars, which represent letters that cannot be decoded. For instance, using the holes 2, 5, 7, 15, 23, 26, 27, 31, 33, the decoded message starts: o*courseire*lizesomeofyo*arebringi*gs*ecialentr*ntswithyouto*
Because this grille contains only one error (the last number should have been 34), this message is almost readable. Using the holes 0, 2, 5, 17, 18, 30, 35, 33, 11 gives
You shouldn’t need the “Reset” button, unless the program crashes. Reset will also return the Cardano Grille to the default one used in the book and the Virgenére key to the Beatles line used in the book.
Frequencies. You can use the software to measure the frequencies of letters in a plain message. Turn off all the codes so that when you encode a message, nothing happens except that everything is capitalized and all spaces and punctuation is lost. The frequency analysis display then shows the frequency in the plaintext. Use the “Display a text message” to pick various messages and look for patterns in the frequency table. As you click repeatedly, you will find some simple messages used for testing the codes, Dr.G’s first Spanish message, evil messages from the end of the book, and the first 2,596 letters from the book. Note the tremendous range of frequencies from almost zero for some letters to well over 10% for E. Look at the slight differences between Spanish and English. Look at the frequencies of other texts and languages by copying and pasting samples of them into the Cyphertext box. You should notice that every text has different frequencies, but that the longer the sample on one language, the less the variations are. Do you see how it is possible to identify the language of a message by looking at its frequencies.
The Caesar Shift. This is the simplest code described in the book. It simply removes each letter and replaces it with one some number of places before or after it in the alphabet. If the key is negative, earlier letters are used; if it is positive, later ones are used. Turn off all the codes except the one called “Shift?” Experiment with shifts of 0, 26, 13, and -13. How does the Caesar shift influence the letter frequencies?
The Virgenére Code. This is like a Caesar shift that changes the amount of shift according to the letters in the key. Try using “aaaa” as the key (don’t forget to turn off the Shift? button and turn on the Vinegére? one). What Caesar shift does this give? What about “bbbb” and “xxxx”? Try a key that uses every letter, like “The quick brown fox jumped over the lazy dog.” Such sentences are called pangrams. Look at the frequency table when you use a pangram. You might think that the frequencies should all be the same, about 3.8%. In fact, frequencies of totally scrambled messages seem to run from about 2% to 5% due to natural randomness. This is much less than the range in any language. What happens to the frequencies when the key contains only a few different letters?
The Super Enigma does a better job at scrambling the letters than Virgenére, which just shifts the letters in the alphabet. Is it better at leveling the letter frequencies? Both the real Enigma and the Super Enigma in the book pick a letter from a new scrambled alphabet for each letter. The Enigma used a mechanical rule to create new alphabets, but the Super Enigma creates each new alphabet almost at random using a random number generator built into NetLogo. The nice thing about the random number generator is that it generates that same sequence of numbers each time it is started. For this reason, it is called a pseudo-random number generator. If it couldn’t repeat, there would be no way to decode a message made with it. The random number generator is started using a seed that is derived from the mater-key, so you change the sequence of pseudo-random numbers by changing the master-key.
The Switching Codes. Experiment with the effect of the Cardano Grille and the Super Cardano Switcher on simple messages, like a bunch of “a”s or the alphabet. These codes change the location of the letters in a message, but do not change the letters themselves. Knowing this, how do you predict they will change the letter frequencies? Try encoding some messages to test your hunch. The Cardano Grille switches the location of letters within 36-letter blocks. The Super Caradano Switcher does not have this limitation—any one letter might end up anywhere in the resulting code, not just within a block of 36 letters. This makes it very hard to decode. To see the difference, start with a plaintext consisting of an “x” followed by 35 “a”s and then a “y” followed by 35 “b”s. What do you predict the two different switchers will do? Do the experiment. Note the locations of the “X” and “Y”.
Breaking Dr.G’s First Code. The first code that Dr. G used as described in the book, was a Caesar shift of –3 followed by a Cardano Grille using the default holes, 3, 5, 6, 10, 13, 15, 17, 27, and 34. To make things harder, the plaintext was in Spanish. The kids in the book broke this code by noticing that the letter frequencies were closer to Spanish than to English, even though the letters were wrong. After staring at the most common letters—B L K and X—they realized that they were just three letters away from common Spanish letters, E O N and I. They found that they could count up three from B to get E, from L to get O, K to get N, and X to get A. This had to be a Caesar shift of –3. Using this information, they eliminated the Caesar shift without even knowing Spanish. They needed a crib or clue, to remove the Cardano Grille that Dr. G used. This is the default grille built into the program.
The Super Codes. The Super Cardano Switcher and the Super Enigma Scrambler can be used together, just by turning on both their switches. Together they make a formidable code. Every letter in the plaintext message is changed into a random letter and is moved to some random place in the encoded message. These are not truly random, because a random number generator sets the rules that make these changes. The random number generator runs through a completely different sequence of numbers, depending on the master key used.