Skip to content

Repository files navigation

crypto-lab-enigma-forge

What It Is

Enigma Forge is a faithful, in-browser simulation of the Wehrmacht Enigma I (3-rotor) cipher machine, paired with the crib + simulated-Bombe attack that broke it. The cipher is a symmetric, electromechanical polyalphabetic substitution: a signal passes through the plugboard (Steckerbrett), three rotors (chosen from I–V, with ring settings and start positions), a reflector (UKW-B or UKW-C), back through the rotors, and out the plugboard — stepping the rotors every keystroke. It solves the problem of a constantly-changing substitution alphabet, and it is its own inverse (the same settings decrypt). It is not secure by any modern standard: a structural flaw (no letter ever encrypts to itself) plus predictable cribs let the demo recover settings by elimination.

When to Use It

  • Teaching how rotor machines actually work — the path visualizer traces a keystroke contact-by-contact, because the mechanism, not a formula, is the point.
  • Demonstrating the no-self-encryption flaw — the empty diagonal is shown interactively and then exploited, making an abstract weakness concrete.
  • Explaining real cryptanalysis — crib placement, menu construction, and the Bombe's deduction-by-contradiction mirror the historical break, not a hand-wave.
  • Showing that keyspace size isn't security — Enigma's ~10²³ keys still fell because exploitable structure leaked; a vivid lesson for modern designers.
  • Do NOT use Enigma for real security. It is broken: it has no forward secrecy, no authentication, a fixed-point-free reflector that leaks structure, and is trivially recoverable from cribbed ciphertext. This is a teaching tool only.

Live Demo

systemslibrarian.github.io/crypto-lab-enigma-forge

Type a message to encrypt it live (and, with identical settings, decrypt it — the machine is its own inverse) while the lampboard, rotor windows, and signal-path diagram update per keystroke. Controls include rotor selection and order (I–V), ring settings (Ringstellung), initial positions (Grundstellung), reflector (B/C), and plugboard pairs (Steckerbrett). The break workflow then takes a crib and ciphertext through placement (self-map rejection), menu construction, and a simulated Bombe that recovers candidate settings you can load back into the machine. Every stop is surfaced only after the crib window is genuinely re-decrypted, and the success banner re-runs that check against the machine's live output rather than trusting that a stop was loaded. Note the honest limit: the Bombe can only deduce Steckers that touch the menu, so a loaded stop reproduces the crib exactly but may leave letters elsewhere transposed until the remaining plugboard pairs are found by hand — the bundled challenge is deliberately one of those cases.

What Can Go Wrong

  • The reflector is fixed-point-free, so no letter ever encrypts to itself — a structural leak that crib placement exploits to reject impossible alignments.
  • Predictable plaintext (stereotyped openings, weather reports) gives cribs that a Bombe-style search uses to eliminate rotor and plugboard settings.
  • Operator procedure failures — reused message keys, lazy rotor choices, repeated indicators — historically shrank the effective keyspace far below its theoretical size.
  • The large keyspace (~10²³) creates a false sense of security; exploitable structure, not brute force, is what broke it.
  • It provides no authentication or integrity and no forward secrecy, so ciphertext can be altered undetectably.

Real-World Usage

  • Historically the primary German military cipher of World War II; breaking it (the Polish Biuro Szyfrów, then Bletchley Park) materially affected the war.
  • A foundational case study in cryptanalysis teaching — known-plaintext attacks, search-space reduction, and why keyspace size alone is not security.
  • The origin point for mechanized codebreaking (the Bombe), a precursor to modern computing.
  • Today purely a teaching and museum artifact, not used for any real protection.

How to Run Locally

git clone https://github.com/systemslibrarian/crypto-lab-enigma-forge
cd crypto-lab-enigma-forge
npm install
npm run dev

Related Demos


Part of the Crypto Lab suite.

"So whether you eat or drink or whatever you do, do it all for the glory of God." — 1 Corinthians 10:31

About

Browser-based Enigma machine demo — full mechanical simulation of rotors, stepping with double-step, plugboard, and reflector, plus the crib-based Bombe break exploiting the no-letter-maps-to-itself flaw. Real wiring tables. No backends. No simulated math.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages