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.
cmake . -DTARGET_GROUP=all
cmake --build .emcc -O3 -s WASM=1 -s EXPORTED_RUNTIME_METHODS='["cwrap"]' -s EXPORTED_FUNCTIONS='["_malloc", "_free", "stringToUTF8", "UTF8ToString"]' -s ALLOW_MEMORY_GROWTH=1 -I src/enigma/ src/enigma/*.c- 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 Ben O'Neill [email protected]. This work is released under the terms of the MIT License. See LICENSE for the license terms.