After working on a M-209 simulator last summer and an Enigma simulator the year before, I got the World War 2 era cipher machine bug again. It all started by reading about the Japanese PURPLE machine at Frode Weierud's excellent CryptoCellar website. I read with great interest a paper available at that site titled PURPLE Revealed: Simulation and Computer-aided Cryptanalysis of Angooki Taipu B by Wes Freeman, Geof Sullivan, and Frode Weierud. This paper is a fascinating read, with detailed descriptions of how the machine worked, the complicated keying system employed by the Japanese, and information on using a technique known as hill-climbing to mount a ciphertext only attack on a messages. Highly recommended!

After reading the paper I knew I had to try to write a simulator for the PUPRLE machine in Python. Writing these simulators is great fun. You have to understand how the machine works, get a bunch of tiny details correct, have a bit of patience, and do a lot of detective work and debugging. Once you have them built, they aren't all that complicated when coded on a modern computer. But you get an amazing appreciation for these machines as originally implemented as electro-mechanical devices. The PURPLE machine, for example, required almost 2,000 wired connections! It is even more amazing when you know the U.S. code breakers built replicas without even seeing an original Japanese machine. When the war ended, only a few parts of one Japanese machine were ever recovered!

I had a lot of fun writing this and playing with it. I hope someone else finds it interesting or educational. Please contact me and let me know if you use it for anything. Please see these links for documentation, the code, and licensing details:

Once again, many thanks to Frode Weierud, Geoff Sullivan, and Wes Sullivan for the very interesting paper. I'm also grateful to Messrs. Weierud and Sullivan who provided me with valuable plaintext, advice and encouragement while I worked on this project.

I also recommend the book Battle of Wits: The Complete Story of Codebreaking in World War II by Stephen Budiansky, which details the efforts and the people behind the cracking of the PURPLE cipher.


comments powered by Disqus