Introduction
The Bazeries cipher is a product cipher from the French cryptanalyst Etienne Bazeries. One secret number does two jobs: its digits split the text into reversed groups, and the number spelled out in words keys a second Polybius square for substitution. Combining transposition and substitution in one key makes it stronger than either step alone. This tool encrypts and decrypts Bazeries in your browser. Enter a number, paste your text, and the output appears instantly. No data leaves your device.
What this tool does
- Encrypts by splitting the text into groups sized by the number's digits, reversing each group, then substituting via two Polybius squares.
- Decrypts by reversing the substitution and then reversing the grouped transposition.
- Builds the substitution square from the number spelled out in English words, deduplicated, with the remaining alphabet appended.
- Uses a standard plaintext square filled vertically and a keyed ciphertext square filled horizontally, with I and J sharing a cell.
- Reports a clear error for invalid keys (non-numeric or containing a zero digit).
How this tool works
The tool takes your number key and uses its digits as repeating group sizes. For encryption, the plaintext is split into groups of those sizes (3, 7, 5, 2, then repeating), and each group is reversed. The result is then substituted letter by letter: each letter is found in the plaintext Polybius square (standard alphabet filled column by column) and replaced with the letter at the same position in the keyed ciphertext square (built from the number spelled in words, filled row by row).
Decryption reverses the steps. Each ciphertext letter is found in the keyed square and replaced with the letter at the same position in the standard square. The result is then split into groups by the number's digits and each group reversed again, which restores the original order. Because the group-reversal step is its own inverse, the same function handles both directions. All processing happens client-side.
How the Bazeries cipher works
Etienne Bazeries was a French army cryptanalyst who, in the 1890s, broke many of the military ciphers of his day. His namesake cipher is a product cipher: it composes a transposition with a substitution so that the weaknesses of each layer are covered by the other. The American Cryptogram Association specifies the version this tool implements: a number under a million, a standard plaintext square filled vertically, and a ciphertext square keyed by the number spelled out in words and filled horizontally.
The two squares are deliberately built differently. The plaintext square is the alphabet in normal order filled top to bottom down each column, so its first row reads A F L Q V. The ciphertext square takes the number (say 3752), spells it as THREESEVENFIVETWO, removes duplicate letters, appends the remaining alphabet, and fills the 5 by 5 grid left to right across each row. Because the two squares use different fill directions and one is keyed, the substitution is a genuine alphabet mixing rather than a simple shift.
The transposition layer uses the digits of the number as repeating group sizes and reverses each group. This breaks up the bigrams and trigrams that frequency analysis relies on, so the substitution layer is harder to attack in isolation. The trade-off is that the same number drives both layers, which creates exploitable correlations. For a pure substitution built on a Polybius square, see the Polybius square tool, and for a pure transposition, see the columnar transposition tool.
How to use this tool
- Type or paste your plaintext into the input field.
- Enter a number key such as 3752. All digits must be non-zero.
- Keep the mode on Encrypt to produce ciphertext, or switch to Decrypt and paste ciphertext to recover the text.
- The tool builds the keyed square from the number spelled in words automatically.
- Use Swap to feed the output back as input and flip the mode in one click.
Real-world examples
Encrypting with the ACA example key
A student follows the ACA example and encrypts "SIMPLESUBSTITUTIONPLUSTRANSPOSITION" with the key 3752. The tool splits the text into groups of 3, 7, 5, 2 (repeating), reverses each group, then substitutes via the two squares built from THREESEVENFIVETWO. The output matches the published ACA ciphertext, confirming the implementation.
Seeing how the number keys the square
A user enters 123 and observes the ciphertext square built from ONEHUNDREDTWENTYTHREE. The letters O, N, E, H, U, D, R, T, W, Y fill the first part of the square, and the remaining alphabet follows. Changing the number to 3752 rebuilds the square from THREESEVENFIVETWO, producing a completely different substitution. This shows how one number controls both layers.
Recovering text with the wrong number
A solver has a Bazeries ciphertext and tries the key 1234. The output is garbage because the substitution square and the group sizes are both wrong. They try 3752 and the plaintext appears. Because the number drives both layers, a wrong number fails completely, which is a useful diagnostic: partial plaintext usually means the right number with a transcription error.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| Polybius square | Single substitution | Coordinate substitution |
| Columnar transposition | Single transposition | Rearranging letters |
| Bazeries | Substitution plus transposition, one key | Product cipher with a number key |
| Nihilist cipher | Polybius plus key addition | Numeric coordinate cipher |
Limitations or considerations
The Bazeries cipher is a historical hand cipher with no modern security value. Because the same number keys both the substitution and the transposition, recovering the transposition key partially constrains the substitution square, which a hill climbing attack can exploit. The number must be under a million in the ACA convention, which gives a small key space (about 11,110 usable keys) when the number itself is the key. Frequency analysis on the substitution layer, combined with anagramming on the transposition layer, breaks it given several hundred characters of ciphertext. Use this tool for education, puzzles, and historical study only.
Frequently asked questions
Why does one number control both the substitution and the transposition?
That is Bazeries' design. The digits of the number set the transposition group sizes, and the number spelled out in words keys the substitution square. It simplifies key memorisation (one number) but creates correlations between the two layers that a modern attack can exploit.
Why are the two Polybius squares filled differently?
The plaintext square is filled vertically (down each column) and the ciphertext square is filled horizontally (across each row) from a keyed alphabet. The different fill directions and the keying make the substitution a genuine mixing of the alphabet rather than a trivial mapping, which is the point of using two squares.
Why must all digits of the key be non-zero?
A zero digit would create a group of size zero, which is meaningless for the transposition. The tool rejects keys containing a zero. The ACA convention uses numbers under a million, so keys like 3752 or 123 are typical.
How is Bazeries different from a plain Polybius substitution?
A plain Polybius square only substitutes letters with coordinates. Bazeries adds a transposition layer (reversed groups) and uses two differently-built squares, so it is a product cipher rather than a single substitution. The combination is stronger than either layer alone.
Conclusion
The Bazeries cipher is a tidy product cipher that uses one number for two layers: a reversed-group transposition and a keyed two-square substitution. Enter a number and a message above to see both layers at work. For the individual components, try the Polybius square and columnar transposition tools, and for another French historical cipher, see the Vigenere cipher tool.