r/madeinpython • u/DrSparkle713 • Mar 09 '22
I made a WWII Enigma machine in Python!
Cryptography has always been an interest of mine, and a bit of a hobby. I have a math/engineering background, and recently came across some well-presented information on how the Enigma machines from WWII worked. I thought it sounded like a fun project, so I coded one up. Check it out and let me know what you think!
There's no UI (sorry). It seems to be working to me. Not really a secure cipher these days, but I thought it would be fun to try and I was happy with the results.
For those familiar with the inner workings of Enigma, I implemented 8 wheels based on wheel specifications found here. My machine allows for any number of wheels, and you can repeat, but if you're trying to be historically accurate you should choose 3-4 unique wheels from the 8. I also implemented a patch board that allows up to 13 patches (any more and you are either repeating or conflicting). I allow for ring offsets as well as message offsets for each wheel. The only thing I don't have a good spec for is the reflector, so I just implemented one that does the job for now. I plan to put something more realistic or something configurable in there later and, if I'm feeling really ambitious, adding a UI to make it easier to use.
Next step: make a Bombe Machine to crack it!