Why build it?
Over the past year I’ve been rebuilding the SG-41 (“Hitlermühle”) as a fully interactive 3D simulation. It’s a machine that doesn’t get much attention compared with Enigma, partly because so few survived and partly because its internal mechanics are complicated.
I wanted to create something that wasn’t just a visual model but a working reconstruction:
- every wheel, lever and pawl is animated based on the real mechanism
- the stepping logic is implemented from historical documentation
- you can type plain text and watch the machine encrypt it in real time
- the whole thing runs in the browser, with no plug-ins
The project started as a way to understand how the SG-41 actually worked, and turned into a deep dive into mechanical cryptography, wartime engineering constraints and some surprisingly elegant design choices.
Research
My information about the SG-41 first came from one of my favourite sites on the internet, cryptomuseum.com, which gives a historical overview of the machine along with photos and details of the mechanism: cryptomuseum.com/crypto/sg41.
One article on that site was especially important to this simulation: Schlüsselgerät 41 by Klaus Kopacz and Paul Reuvers (Crypto Museum, 6 February 2021). It is an in-depth technical description of a real SG-41 that they were able to examine and document. It gave a great, detailed overview of how the mechanism works, and this simulation would not have been possible without it.
I first saw the inside of the SG-41 when I found that the Deutsches Museum had, between 2020 and 2023, carried out computed tomography (CT) scans of many of its cipher machines. CT is based on X-rays, so objects can be scanned in three dimensions to show interior detail not normally visible. There are two SG-41 machines and an SG-41Z numbers-only machine that you can view in full 3D and slice through to see inside in detail: digital.deutsches-museum.de/en/projects/3d-cipher.
From CT scans to 3D models
The Deutsches Museum has also made the CT data available to download: a stack of images, like slices through the machine from top to bottom. After several attempts and a bit of resizing, I managed to load them into a free program called 3D Slicer. It is mainly used for viewing and extracting models from biological samples, but it works well for hardware too, it turns out.
I began to believe it might be possible to rebuild the machine as a working simulation, although at first the amount of work needed to understand, model and animate the whole machine looked like a huge hill to climb. I certainly didn’t understand every part of the mechanism at that point, but I felt I knew enough to make a start and work out the rest as I went.
3D Slicer let me not only view the interior as models, but cut out sections, so each component or group of components could be exported as a 3D mesh. The machine is very complex and tightly packed, so being able to chop away the case or other sections to extract and look at the part of the mechanism I was interested in was perfect.
Modelling in Blender
Once I had a set of usable 3D models, I imported some of them into Blender, another amazing free application, which I used to model each component by hand.
Each gear, cam, lever and spring was brought into Blender one at a time as a mesh, resized and positioned to fit the machine’s layout. With each rough component in place, I could use Blender’s modelling tools to create an accurate 3D model of it, saved as a glTF file (GL Transmission Format), which is a bit like the JPEG of 3D files.
Bringing it to the browser
The final step is to load these glTF files into my HTML and JavaScript pages so they can be shown in a web browser. The rendering and animation are done by a JavaScript library called three.js, another amazing piece of free work, which renders and animates 3D objects very quickly, even on lower-end computers. This matters to me: I always want to give as many people as possible the chance to try these machines and learn about them, so running in a browser, without downloading a version for a particular type of computer, is always high on my list.
Thanks to GCHQ
One big help along the way was an invitation from GCHQ to see their SG-41, which is in great condition. It let me see and record the mechanism working, and answer some questions that can’t always be answered fully just by looking at a static image. Many thanks to GCHQ for that opportunity.
The making-of videos
A YouTube playlist of videos I made while building this simulation, explaining much of how the SG-41 works as I discovered it: the Virtual SG-41 YouTube playlist.