Introduction
The Lorenz SZ40 and SZ42 were cipher attachments used by the German High Command in WWII to protect strategic teleprinter traffic. The British called the system "Tunny." Unlike the Enigma machine, which used mechanical rotors, Lorenz was a Vernam stream cipher that XORed 5-bit Baudot-coded plaintext with a keystream from 12 rotating wheels. Bill Tutte reverse-engineered the machine logic from intercepted messages in 1942 without ever seeing the device. Bletchley Park then built Colossus to break Tunny traffic at scale. This simulator implements the 12-wheel stepping with ITA2 Baudot encoding. Set the wheel start positions, type your message, and watch the Chi, Psi, and motor wheels step. All processing is local.
What this tool does
- Simulates the Lorenz SZ40/42 keystream with 12 wheels: 5 Chi (41, 31, 29, 26, 23), 5 Psi (43, 47, 51, 53, 59), and 2 motor wheels Mu61 and Mu37.
- Encodes and decodes text using ITA2 Baudot code with XOR keystream generation. Encryption and decryption are the same operation.
- Implements conditional Psi stepping: Mu61 controls Mu37, and Mu37 controls whether all Psi wheels advance per character.
- Lets you set the start position for each of the 12 wheels, or randomize them with one click.
- Displays final wheel positions and a per-character trace table showing Chi, Psi, motor positions, and whether Psi stepped.
- Runs entirely in your browser. No input data is sent to any server.
How this tool works
The tool initializes 12 wheels with the historical Lorenz lengths and your start positions. For each character, it converts to 5-bit ITA2 Baudot code, then computes the Chi key by XORing the current cam bit from each Chi wheel. It checks the motor: if Mu61's current cam is set, Mu37 steps. If Mu37's current cam is set, all 5 Psi wheels step. The Psi key is the XOR of the 5 Psi wheel current bits. The final key is Chi XOR Psi, and the ciphertext is plaintext XOR key. All Chi wheels and Mu61 step after every character.
The trace table shows wheel positions per character, with Psi positions dimmed when they did not step. Characters not in the ITA2 letter set pass through unchanged without stepping wheels. The current wheel positions are encoded in the URL.
How the Lorenz SZ40 cipher works
The Lorenz SZ40 was manufactured by C. Lorenz AG in Berlin. The German military used it from 1942 for traffic between the Oberkommando der Wehrmacht and field headquarters. The device sat between a teleprinter and a radio transmitter, XORing Baudot-coded plaintext with a wheel-generated keystream. The Wikipedia article gives a detailed overview.
The 12 wheels had adjustable cams (levers set on or off). The cam pattern on each wheel was part of the key. The 5 Chi wheels stepped every character. The 5 Psi wheels stepped only when the motor allowed it, so the Psi key changed irregularly. This was its main strength: the Chi key was regular, but the Psi key was not.
Bill Tutte, a chemist recruited to Bletchley Park, deduced the machine structure in 1942 from a single retransmitted message where the operator used the same wheel settings with slightly different abbreviations. He worked out the wheel lengths, Chi/Psi split, and motor mechanism by hand, without ever seeing a Lorenz machine. See the Codes and Ciphers Heritage Trust.
Bletchley Park then built Colossus, designed by Tommy Flowers at the Post Office Research Station, to automate breaking Tunny. Colossus first ran in December 1943 and was the first programmable electronic digital computer. The National Museum of Computing houses a rebuilt Colossus. Tony Sale led the rebuild and documented the Lorenz mechanism.
This simulator uses all cams set to 1 by default, simplifying the key to the 12 wheel start positions. The real machine had configurable cam patterns on every wheel. The Vernam cipher is the theoretical foundation: Lorenz is a Vernam cipher with a pseudorandom keystream instead of a one-time pad.
How to use this tool
- Choose a mode: Encode to encrypt, or Decode to decrypt. Both use the same XOR operation.
- Set the start position for each of the 12 wheels. Use the Random button to generate a valid set of positions, or enter them manually.
- Type or paste your text. Only letters A-Z and spaces are encoded via ITA2 Baudot; other characters pass through unchanged.
- The output updates instantly. The ciphertext (or recovered plaintext) appears in the output field.
- Enable Show wheel stepping to see the final wheel positions and a per-character trace table showing how Chi, Psi, and motor wheels advance.
- To decrypt, use the same wheel start positions and switch to Decode mode. The XOR symmetry recovers the original text.
Real-world examples
Encrypting a strategic message
An instructor sets all 12 wheels to position 0 and types "ATTACK LONDON AT DAWN". The tool converts each letter to 5-bit ITA2 Baudot code, generates the Chi-Psi keystream, and XORs it with the plaintext. The output is a string of seemingly random letters. The per-character trace shows the Chi wheels advancing every character while the Psi wheels step only when the motor allows it.
Round-trip encryption and decryption
A student encrypts "HELLO WORLD" with random wheel positions, copies the ciphertext, then pastes it back with the same positions and switches to Decode. The original plaintext is recovered, demonstrating that Lorenz is a symmetric Vernam cipher where encryption and decryption are the same XOR operation.
Observing the irregular Psi stepping
A cryptography class enables the trace table and types a 20-character message. The Chi positions increment by 1 every character, while the Psi positions stay flat for several characters, then jump. The "Psi step?" column shows exactly when the motor triggered a Psi advance. This irregularity made Lorenz harder to break than a simple repeating-key cipher.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| Lorenz SZ40/42 | O(n) with 12-wheel keystream | WWII German High Command strategic traffic |
| Enigma (3-rotor) | O(n) with rotor permutations | WWII German field communications |
| Vernam / one-time pad | O(n) with random key | Theoretically perfect secrecy |
| RC4 | O(n) with 256-byte S-box | Legacy stream cipher, broken |
Limitations or considerations
This simulator is simplified for education. It uses ITA2 letter shift only (A-Z and space). The real Lorenz also supported figure shift for digits and punctuation. All cams default to set (1), reducing the key to the 12 wheel start positions. The real machine had configurable cam patterns on every wheel, giving a much larger key space. Non-ITA2 characters pass through unchanged, so their positions are visible in the output. Lorenz is completely insecure by modern standards. It was broken by hand methods and Colossus during WWII. For real encryption, use AES-256. See the RC4 cipher tool for another historical stream cipher, or the Vernam cipher tool for the one-time pad theory that Lorenz approximated.
Frequently asked questions
How is Lorenz different from Enigma?
Enigma used mechanical rotors that stepped per character and a reflector that made it self-reciprocal. Lorenz had no rotors or reflector. It used 12 wheels with adjustable cams to generate a keystream that was XORed with 5-bit Baudot-coded plaintext. Lorenz was a stream cipher; Enigma was a rotor machine. Lorenz protected strategic High Command traffic, while Enigma was used for field communications.
Who broke the Lorenz cipher?
Bill Tutte reverse-engineered the machine's logic in 1942 by analyzing intercepted traffic, without ever seeing the device. Tommy Flowers designed and built Colossus at the Post Office Research Station to automate the cryptanalysis. Colossus first ran in December 1943 at Bletchley Park. Tony Sale later led the rebuild project, now on display at The National Museum of Computing.
Why do the Psi wheels not step on every character?
The Psi wheels step only when both motor conditions are met: Mu61's current cam must be set (which steps Mu37), and Mu37's current cam must be set (which steps all Psi wheels). This creates an irregular stepping pattern that makes the Psi key harder to predict. The Chi wheels step on every character, making their key regular and easier to analyze.
Is Lorenz encryption the same as decryption?
Yes. Lorenz is a Vernam stream cipher based on XOR. XOR is its own inverse, so applying the same keystream to the ciphertext recovers the plaintext. The tool provides both Encode and Decode labels, but the underlying operation is identical. Both sides must use the same wheel start positions and cam settings.
Conclusion
This simulator reproduces the 12-wheel Lorenz SZ40 keystream with ITA2 Baudot encoding. The trace table makes the irregular Psi stepping visible, which distinguished Lorenz from simpler stream ciphers. The tool is useful for teaching WWII signals intelligence and stream cipher design. For modern encryption, use AES-256. To explore related ciphers, try the Enigma machine simulator, the Vernam cipher, the RC4 cipher, or the ADFGVX cipher.