Skip to content

# Cryptography Lab

A hands-on cryptography lab with 12 workbenches, each showing its intermediate state, not just an answer. These are teaching tools; don't use classical ciphers for real secrets.

Rendered when the site was built. No JavaScript required. With JavaScript on, this is replaced by the interactive lab, where the same Enigma is driven from your own settings. Every transform is also available offline via `crypto-lab-cli`. The lab's other eleven workbenches need JavaScript, Enigma is prerendered here because its wirings and stepping are fixed tables; the rest compute from what you type. All of them are available offline through the same CLI.

## Enigma: rotor and reflector wirings

Each wheel is a fixed permutation of the alphabet. A rotor's notch is the window letter at which it carries the wheel to its left on the next keypress; reflectors never turn.

Enigma wheel wirings (A–Z in, these letters out)
Wheel | Wiring | Notch
--- | --- | ---
I | EKMFLGDQVZNTOWYHXUSPAIBRCJ | Q
II | AJDKSIRUXBLHWTMCQGZNPYFVOE | E
III | BDFHJLCPRTXVZNYEIWGAKMUSQO | V
IV | ESOVPZJAYQUIRHXLNFTGKDCMWB | J
V | VZBRGITYUPSDNHLXAWMJQOFECK | Z
VI | JPGVOUMFYQBENHZRDKASXLICTW | Z, M
VII | NZJHGRCXMYSWBOUFAIVLPEKQDT | Z, M
VIII | FKQHTLXOCBJSPDZRAMEWNIUYGV | Z, M
Beta | LEYJVCNIXWPBQMDRTAKZGFUHOS | none
Gamma | FSOKANUERHMBTIYCWLQPZXVGJD | none
UKW-B | YRUHQSLDPXNGOKMIEBFZCWVJAT | n/a: reflectors do not step
UKW-C | FVPJIAOYEDRZXWGCTKUQSBNMHL | n/a: reflectors do not step
UKW-B thin | ENKQAUYWJICOPBLMDXZVFTHRGS | n/a: reflectors do not step
UKW-C thin | RDOBJNTKVEHMLFCWZAXGYIPSUQ | n/a: reflectors do not step

## A worked example, and the double-stepping anomaly

Six presses of the `A` key on wheel order I II III, rings `AAA`, started at `ADU`. The middle rotor steps on two consecutive keypresses: once because the right rotor passed its notch, and then again because the middle rotor was itself sitting on its own notch. A geared odometer cannot do that, and it is why the machine's 17,576 start positions are really only 16,900.

    machine        M3 (3 rotors)
    wheel order    L=I  M=II  R=III
    reflector      UKW-B
    Ringstellung   A A A
    Grundstellung  A D U
    Steckerbrett   (none)

    in   AAAAA A
    out  EQIBM G

    Rotor stepping: the window letters at the moment the circuit closed
    (the wheels advance *before* the current flows, never after)

    key   L M R  pawls   why
     A    A D V      R
     A    A E W    M R   III passed its notch (V) and carried II
     A    B F X  L M R   << DOUBLE STEP: II sat on its own notch (E) and stepped itself, carrying I
     A    B F Y      R
     A    B F Z      R
     A    B F A      R

    1 double step in 6 keypresses. On a car odometer the middle wheel moves once per ten of the fast wheel. Here the pawl rests on the middle rotor's own notch, so the middle rotor drags itself round a second time on the very next key, and the wheel order's turnover letter is skipped, not repeated.

Three of the workbenches have a single-purpose tool beside them: the File Hasher & Checksum Verifier runs the same digests over a whole file, the Password Generator makes the kind of secret the key-derivation tabs are built to stretch, and the JWT Decoder opens a real signed token of the sort these primitives end up protecting.

About this lab4 paragraphs

The workbenches: a Vigenère cipher workbench (watch the repeating key stream and per-letter shifts), a frequency-analysis workbench (the letter histogram, index of coincidence, and best Caesar shift), an XOR / one-time-pad sandbox (the XOR laid out byte by byte), and a hash & key-derivation explorer (MD5/SHA/BLAKE3 digests and a PBKDF2 trace).

Then the modern primitives (AES rounds, RSA / Diffie–Hellman, HKDF, ChaCha20, elliptic curves, Argon2id and Ed25519), and an Enigma M3/M4 that draws its own electrical path.

Four tabs take a secret rather than a teaching input: the XOR / one-time-pad key, the hash & KDF field (which is used as a password), the Argon2id password, and the Ed25519 seed, which is the private key. Each of those four is gated behind its own short acknowledgement, so opening one does not open the others.

The Enigma tab is not gated: a 1930s key sheet over a broken cipher is not a secret.

Use it locally This lab has a native command line twin. Build `crypto-lab-cli` from the site's source with:

    cargo build --release --bin crypto-lab-cli

Source and licence terms