r/madeinpython • • 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!

My GitHub repo

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!

28 Upvotes

5 comments sorted by

4

u/maifee Mar 09 '22

Try to add some UI. I remember I did something with Java back in 2020 as my course work: https://github.com/maifeeulasad/Enigma-Emulator

2

u/DrSparkle713 Mar 09 '22

Oh, cool, thanks for showing me. And you have some great work on there!

2

u/ArionRefat Mar 09 '22

Saw your profile, you are really a hard working and dedicated guy.

3

u/maifee Mar 09 '22

Thanks and keep me in your prayers.

2

u/mikespon Mar 09 '22

Great work. Cant wait to try it out. Thanks for sharing!