Build a simple polyalphabetic cipher machine
A Simple Two-Gear Cipher Machine
This simple machine uses two gears to make a polyalphabetic cipher machine. The gears can be made of heavy card stock or thin wood, and are easily cut by hand. You can print the two gear images and glue them to the material you cut the gears from. The two gears are each mounted on a dowel for an axle, but you want to be able to lift them off the axle in order to reset the machine to its starting position.

Using the Machine
The right hand wheel is the plaintext wheel, and the left hand wheel is the ciphertext. Begin by setting the machine up in the starting locatio as shown in the figure above. Find the first letter of the plain text message on the right hand wheel, and turn the wheel clockwise until that letter is touching the ciphertext wheel. For example, suppose the message is
otto has the diamonds
By turning the plaintext wheel clockwise, eventually the first letter in the message, o will line up with N on the ciphertext wheel. Write down this first cipher letter inder the first letter of the original message:
otto has the diamonds
N
The continue turning clockwise (never turn the wheel backwards) until you line up the next letter of the message, t. That letter will line up with M on the Ciphertext wheel, so copy M to the message:
otto has the diamonds
NM
Now you will notice that the letter t repeats in the plaintext message. Do not repeat the cipher letter M. You will notice that there are sseveral asterisks on the plaintext wheel. These are used to indicate doubled letters. When encrypting the second letter of a double pair, use the next available asterisk instead of encrypting the same letter twice. In other words, you will encrypt otto as if it actually read ot*o. The next asterisk lines up with the letter P, so that is what is written.
When you decrypt a message and find an asterisk in the plaintext message, write that down as a repeat of the letter just before the asterisk. So if, while encrypting, you find the word lit*le, write that down as little.
SPECIAL NOTE: This asterisk rule can be tricky because it must also be applied when a word begins with the same letter that ended the previous word. Therefore, my yellow wagon has to be encrypted as my *ellow *agon.
ot*o has the diamonds
NMP
You might wonder why we couldn't just encrypt double t by turning the plaintext gear one whole turn to the next occurance of t. That loooks like it would work, but for a simple reason having to do with modular arithmetic, the resulting message cannot be decrypted properly. This is because in picking the next ciphertext letter we pass over another copy of that same letter, so when we go to decrypt the message, we end up using the wrong copy of the ciphertext letter. Try it for yourself with the gears. (or with this simulation program. When you encrypt otto that way you get NMLM. But if you try to decrypt NMLM you end up with otwr instead of otto.
We then continue clockwise on the plaintext wheel until we find the next letter o, which now aligns with X on the ciphertext wheel.
Continuing in this manner we can encrypt the entire message:
ot*o has the diamonds (Remember to use '*' instead of the second double letter.)
NMPX RUF IAA MBMCWTIM
You will notice that the same plaintext letters are encrypted differently each time they occur, and that the same ciphertext letter can also stand for different plaintext letters. This is because the cipher continuously changes each time the wheel is turned. This makes the cipher immune to simple substitution attacks such as might be used to solve a newspaper cryptogram puzzle.
Decrypting the message works the same way except that you look for the ciphertext letters on the left wheel and read off the decrypted message from the right wheel. The asterisks on the right wheel are nulls and can be ignored. They are there to make the number of teeth on the right wheel a prime number. If when decrypting a message the plaintext wheel shows asterisk as the decryption, keep turning the wheel until the same ciphertext letter comes all the around again to get the correct decryption.
Before encrypting or decrypting a message be sure to reset both gears to the starting position shown in the figure above. You may also decide to use a different, secret starting position that you share with the message recipient, in case someone else who has built the same machine intercepts your message.
Try a Simulation of This Machine
CLICK HERE to try out an online simulation of this machine.
Some Interesting Problems with This Machine
In spite of the precautions taken to be sure double letters decrypt properly, there are still some situations where the ciphertext does not decrypt properly. For example, the plaintext john has the diamonds encrypts as WNWS RUF IAA MBMCWTIM, but this ciphertext decrypts as john has the gkdprs*y.
When something like this is encountered, the only solution is to back up to the point where the error occurs and make one additional full turn of the ciphertext wheel before continuing to decrypt the message. This will correct the error.
The problem has to do with letters being adjacent, or very close toegther in the normal alphabetical sequence, but in wrong order. For example, in the word money the o is followed immediately by n. In alphabetical order, these two letters are also adjacent, but in opposite order. Because of this they are nearly doubled letters, and behave as a doubled letter does. The word money encrypts to RNSWV which, in turn, decrypts to moqha instead of money.
I haven't yet come up with a good way to fix this problem. A computer program employing this method could simply do a trial decryption as it was doing the encryption, and whenever the decryption didn't match, insert a null * to resynchronize the gears. For example, mo*ney encrypts as RNASWV which decrypts properly as mo*ney.
The full size patterns

An Inside-Out Variation
This variation puts the 26-tooth ciphertext wheel inside a 31-tooth plaintext gear with inward-facing teeth. The plaintext outer gear remains staionary and the inner gear is dragged around clockwise inside the outer gear by placing a finger in the center hole. Other than that, the operating principle is the same.
Other Variations
Another variation is two side-by-side rings with gear teeth on the inside and connected by a common idler gear. The alphabets could be printed on the outside of the rings and the gearing mechanism would be completely hidden inside, in the style of a mechanical odometer.
Much more complex ciphers could be realized by replacing the gear wheels with long sprocketed loops, much like movie film, with a different plaintext or ciphertext letter in each frame. A pair of side-by-side sprocket wheels would advance these two ribbons in an asynchronous manner, continually shuffling the alphabets relative to each other. Long loops with a prime number of frames could result in polyalphabetic ciphers with repetition periods in the tens of thousands of characters.
MARK II -- A Simpler Design Without Decryption Problems
A simpler cipher machine design that does not have the same decryption problem of the above machine uses a 25-tooth plaintext wheel and a 26-tooth ciphertext wheel. The plaintext wheel is missing the letter q, and k is substituted, as in the kuick brown fox .... Because there are no nulls, and because the ciphertext wheel is smaller than the plaintext wheel, it is not possible to end up with the kind of situation that resulted in decryption errors in the above design.
Here is the link to the simulator for the MARK II cipher machine.
If the letter q is actually needed in a message, such as in giving part numbers, or map coordinates, the correspondents can agree on some circumlocution such as spelling it out kew.
This machine has a repeat cycle length of 25 * 26 = 650, although because the alphabet is not always completely cycled with each letter, the message length before a repetition will be somewhat longer than 650 characters, depending on the nature of the message.
The cipher produced by this machine has the weakness that when the cipher alphabet is advanced, it is always advanced by one letter. Knowing this would make the task of cracking the cipher somewhat easier. On the plus side, the cipher alphabet is advanced at somewhat irregular intervals depending on when the plaintext wheel completes a whole revolution, which, in turn, varies with the content of the plaintext message.
A Sample From the Simpler Machine
otto has the diamonds
NAXR OEZ NFG EPAOQOKC which correctly decrypts to:
otto has the diamonds
The full size patterns
This machine uses the same ciphertext wheel as the machine above, so only the pattern for the 25-tooth wheel is necessary.
If you decide to build the MARK II machine and get really ambitious, here's a message for you ro decrypt: (Set the starting position to "aH".)
FBDW DP VNIUYBQ. RUVE JYSQC JYI- PXCSF LALR SLO KEMR YEWQRYCNH- WPYUZV DQSJCB WT CU VCVYN GI PR ICIOS, TGZ LGFSXEN LCLBNCGJIK YS WNKOSISX DP TW ZFWTG, F RHCRGBD B ROWHX VZYG RZHVI D YXPHAD VAC YCQ MUO YBXFNY RERN WB RHE ZVCPA.
As an aside, if you want to design your own variations, here is an excellent free web-based application that will draw gear patterns for you. When you visit that page be sure to scroll all the way down the page and read all the instructions so you can take full advantage of all the features.