This is a simulation of an 1938 Army M3 five-rotor military Enigma machine.

Use the arrow keys to navigate between screens. Use the keyboard keys to interact with the machine's keyboard and plugboard. Use the number keys 1-5 to interact with the rotors. The rotors are above the keyboard, while the plugboard is below.

If you're unfamiliar with the Enigma machine, the YouTube channel Numberphile has a great video breaking down how it works and why it was hard to crack, which includes a live demo of the machine (please note that they using a fully-wired plugboard before you attempt to replicate their demo in this simulator).

---------- Questions You Might Have ----------

Why did you build this in PICO-8? Isn't that restrictive?

Short answer: Yes. I'm a theoretical computer scientist. We tend to enjoy approaching problems in obtuse ways to see what happens.

Long answer: I built this in PICO-8 for fun, mostly. PICO's a neat little tool, and with some finagling with memory you can get the keyboard and alternate palettes working, without which this project wouldn't be possible. With an actual game engine, there's a ~90% chance I would have expanded the project to include other machines (like the Typex, for instance) and put far too much time into it. PICO keeps the project "byte-sized" in more ways than one.

Isn't the phrase "bite-sized"?

Yep, "byte-sized" is a computer science pun. In computer memory, a byte is a collection of 8 bits, where a bit can be either 1 or 0. 

Is this machine historically accurate?

Visually? No, aside from the German board layouts and relative positioning of the rotors, keyboard, and plugboard. The real Enigma machines were much higher resolution, if you can believe it.

Functionally, though? It should be, yes. My version seems to be consistent with other Enigma simulators I've been able to find online (couldn't possibly get my hands on a real one), and the rotor wiring and turnover positions are accurate and based on the original wiring/specs.

This sim uses the most famous setup (though many others exist), with rotors I-III from the Enigma I model, and rotors IV and V added to the M3 in late 1938. Only three rotors can be used at a time from the pool of five. It also uses Reflector B ("Wide B").

I think I found an issue in the simulator, can you fix it?

Yep, though I can't promise it'll be quick. If you think you've found an error, please do double check that it actually is an error first.

For instance, if you're trying to decrypt a message, please ensure that you have all the information on the initial configuration, including correct rotors, rotor positioning, rotor rotation, and plugboard connections. Also note that the machine state will change position over time; the machine moves the rotors each time a key is pressed. Also note that in the current build, if you hold down a key for too long it will count as multiple presses, which may cause manual input errors.

I also found while testing that a lot of video examples I tried to recreate would (for some reason) leave out the fact that they'd set up the plugboard, or wouldn't provide info on which rotors or positions they were using. In weirder cases they'd be using a variant model of the Enigma (there were several). 

Where can I learn more about the Enigma machine?

If you're just curious about the machine or don't know how it works, I always recommend the Numberphile video on how the machine works (it also has a bunch of math, fancy that!). The channel Computerphile also has numerous videos on Enigma, both historical and technical.

For technical details, a lot of the rotor and wiring information can be found on Wikipedia. There's also a list of variations on the machine as well, if you're curious.

For info on Alan Turing (the man who was instrumental in cracking Enigma) and a dive into his work, I highly recommend the biography Alan Turing: The Enigma by Andrew Hodges. It covers a lot about Turing's personal life, as well as breakdowns of his technical work in mathematics that are now foundational in computer science.

I personally recommend against watching The Imitation Game. It has a lot of historical inaccuracies introduced for the sake of drama.

Are you going to update this machine, or built other ones?

Update? Yes, there will be minor fixes and tweaks. Others? Possibly. In it's current state this one needs a bit of polishing and QOL fixes.

I may build other compsci/crypto projects in the future, for the fun of it.

Leave a comment

Log in with to leave a comment.