Enigma Machine Sim banner

Enigma Machine Sim

6 devlogs
19h 35m 42s

simple simulation of the enigma machine

Demo Repository

Loading README...

sbalaj

Shipped this project!

this is a simulation in c of Enigma I from 1930 with the UKB-W reflector. my, lets say, unique, design means that the rotors are hardwired to have their scrambling entirely horizontal, so the path is routed between the gaps, as opposed to within the rotor like the actual machine, however this is just a cool visual, and it still works the same. the letters per each output won’t directly match the visual due to the rotation, since the input and output are each shifting relative to themselves, however each signal is still correct, and the output into the static wheel is the actual output you would receive. you can verify it with the online tool at https://www.101computing.net/enigma-machine-emulator/

since this project was built up in c, its a minor miracle that i got the web version compiled in the first place. the ui on the web demo is from the compile tool emscripten, and the console is just the output interface you can use to trace the signals through the system.

sbalaj

i never got around to getting plugboard functionality but i’ll have to do that soon (some day). the wiring actually works now, as you can see by where it gets output. this was a pretty fun project, and my code is a genuine abomination, but this was a pretty fun project.

Attachment
0
sbalaj

i said i would do it. i did say i would do it. did they listen? did they harken to my words? i dont know, i dont know anymore, maybe you should ask them, maybe they have what you want. the visuals are a little barebones however it’s something, and i think it looks cool. i’m still figuring out the exact wiring, it doesn’t actually correspond correctly yet, however the outputs do work in the terminal,
which is in fact what i’m using to sanity check each step. the code for those wires is a genuine atrocity. a bete noire if you will. but oh well, if it works it works (it doesn’t work right now though)

Attachment
0
sbalaj

fixed enigma machine, should have working cli operation. switched characters to being 0 index to fix the issue with the mod.

also planned out the graphical layout and started rendering the keyboard.

Attachment
Attachment
0
sbalaj

added reverse rotor functionality, this is getting trippy. the reverse enciphering is definitely broken since it may output a negative number if the wheel rotates too much but I’ll just have to fix that later. for the most part, or rather, for at least a couple inputs (I’ve only tested a couple) it seems to be working correctly

Attachment
0
sbalaj

separated modular functions into individual files and switched to the three rotors of Enigma I. now utilising an initialiser function to install all three rotors, allowing for changes in the ordering.

one key concept that took some time to understand is that the wiring of each rotor was exclusively within itself. That means, when a rotor rotates, functionally, the input is shifted by one, the mappings themselves never change, as is often easy to visualise. the implication this returns when simulating a compartmentalised process is that both inputs and outputs have to be shifted in accordance with rotation. a rotor shifted one place takes the input ‘A’ into the ‘B’ wiring, and the ‘B’ connection is what is activated on the other side of the rotor. Significantly, if ‘B’ corresponds to a ‘D’, then the next rotor does NOT receive an input of ‘D’, but rather an input of ‘C’, since the first rotor has been shifted by one position.

Attachment
0