libenigma
Enigma machine utility library
Loading...
Searching...
No Matches
libenigma

enigma

An Enigma machine simulator and toolset for cryptanalysis

CI status. Doxygen status clang-format status Demo status Coverage

Table of Contents

  • Overview
  • About the Enigma
  • Building
  • Testing
  • Further Reading
  • License

Tool Documentation

Overview

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.

About the Enigma

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.

Building

# build library and tools
cmake -S . -B build
cmake --build build
# build web demo
./build_webdemo.sh
# install library and tools
cmake --install build

Testing

git submodule update
cmake -S . -B build -DTEST=ON
cmake --build build
cd build
ctest --verbose

Further Reading

License

Copyright (c) 2025-2026 Ben O'Neill ben@o.nosp@m.neil.nosp@m.l.sh. This work is released under the terms of the MIT License. See [LICENSE](LICENSE) for the license terms.