This is a full-featured C99 library and toolset (with WebAssembly support) for simulating and cracking the Enigma.
The library and toolset currently supports simulating all common 4-rotor military Enigma configurations used in World War II. It also supports cracking ciphertext utilizing Index of Coincidence and n-gram analysis.
An online demo is available.
The Enigma was a cipher device used by the Germans during World War II to encrypt military communication. It uses a very complex wiring system to scramble the input.
When a key is pressed, the signal first passes through the plugboard, which swaps the letter with another according to its configuration. It then travels through three rotors, each further scrambling the signal. Next, the signal reaches the reflector, which further scrambles the signal. Then, the signal passes through the rotors again in reverse. Finally, the signal passes through the plugboard again, and the resulting encoded letter lights up on the lampboard. The Enigma's encryption was symmetric — ciphertext is decrypted using the same key as was used to create it.
# build library and tools
cmake -S . -B build -DTARGET_GROUP=all
cmake --build build
# build web demo
./build_webdemo.sh
# install library and tools
cmake --install buildgit submodule update
cmake -S . -B build -DTARGET_GROUP=test
cmake --build build
cd build
ctest --verbose- The Cryptographic Mathematics of Enigma
- Enigma Cipher Machine on Crypto Museum
- The Turing-Welchman Bombe (National Museum of Computing)
- Cracking Enigma in 2021 (Computerphile on YouTube)
Copyright (c) 2025-2026 Ben O'Neill ben@oneill.sh. This work is released under the terms of the MIT License. See LICENSE for the license terms.