Bazeries Cipher
Encode and decode the Bazeries cipher, the two-stage system devised by the French cryptanalyst Étienne Bazeries in which a single secret number does two jobs at once. Its digits cut the message into groups that are each reversed, and the same number spelled out in words keys a substitution square laid beside the plain alphabet. Pick your number, switch between encode and decode, and watch both squares fill while the transposition and substitution play out letter by letter. Everything runs in your browser.
Number
Spelled out, the number keys the right-hand square; its digits set the transposition group sizes. The classic example uses 23.
Live cipher squares
Square 1 — plain alphabet, down the columns
Square 2 — keyed by the number, across the rows
Square 2 key: TWENTYTHREE
Enter text above to see the Bazeries cipher result here.
How to use Bazeries Cipher
- 1
Choose encode or decode
Pick Encode to turn plaintext into Bazeries ciphertext, or Decode to turn ciphertext back into plaintext. The same secret number is used in both directions.
- 2
Enter the secret number
Type a whole number from 1 to 999999. The tool spells it out to key the right-hand square and uses its digits to size the transposition groups. The two live squares show exactly how your number arranges the alphabet.
- 3
Type or paste your text
Enter your message or your ciphertext. The cipher runs automatically, reversing each number-sized group and substituting between the two squares, with a stage-by-stage view of the working.
- 4
Read, copy, and share
Read the result, then copy it, download it as a text file, or share a link that reopens the tool with your exact number, direction, and text. Everything stays in your browser.
Understanding the Bazeries cipher
What is the Bazeries cipher?
The Bazeries cipher is a two-stage pencil-and-paper cipher named after Étienne Bazeries, the celebrated French army cryptanalyst of the late nineteenth century. What makes it elegant is that a single secret number controls the whole system. The same number is used in two different ways: read as a sequence of digits it drives a transposition, and spelled out as a word it keys a substitution. Combining a transposition with a substitution like this is what cryptographers call a product cipher, and it makes the Bazeries cipher noticeably stronger than either step would be alone.
Both stages work on a 25-letter alphabet in which I and J share a cell, the same convention used by the Polybius square and the Playfair cipher. The encoder first reverses small groups of letters, then replaces each letter using two squares set side by side. Because the two squares are built in deliberately different ways, the substitution is not a simple shift but a genuine mixing of the alphabet. The result hides both the order of the letters and their identity, which is exactly the combination Bazeries was after.
How the Bazeries cipher works
Two 5x5 squares sit next to each other. Square 1 holds the plain alphabet, but written downward along the columns, so reading its rows gives A, F, L, Q, V on the first line, then B, G, M, R, W, and so on. Square 2 is the keyed square: the secret number is spelled out in words, its repeated letters are struck out, and the leftover alphabet is appended, all written across the rows in the normal left-to-right reading order. With the number 23 the keyword is TWENTYTHREE, which trims to TWENYHR, so square 2 reads TWENY on its first row, then HRABC, and the rest of the alphabet follows.
Enciphering happens in two passes. First the transposition: the plaintext is cut into consecutive groups whose lengths are the digits of the number taken in turn and repeated, and each group is written out backwards. With the key 23 the message is split two letters, three letters, two, three, and so on, and every little group is reversed. Second the substitution: each letter of that transposed text is located in square 1, and the letter occupying the very same cell of square 2 is written down in its place. Decoding simply runs the machine backwards, undoing the substitution from square 2 to square 1 and then reversing the same groups a second time to restore their original order.
Worked example
Take the word DCODE with the key 23. The digits 2 and 3 split it into DC and ODE, and reversing each group gives CD and EDO, so the transposed text is CDEDO. Now substitute. In square 1 the letter C sits in the cell that, in square 2, holds D; likewise D maps to L, E maps to S, the second D again to L, and O maps to O. Reading those off gives the ciphertext DLSLO. This DCODE to DLSLO result is the standard reference vector for the Bazeries cipher, so you can use it to check any implementation, including this one.
A longer message shows the mixing better. Enciphering WEHAVETAKENTHEBRIDGE with the same key 23 produces SCYTFPSSUTPGHSFMBSRL. Notice that the two copies of the letter pattern in the plaintext do not line up neatly in the ciphertext, because the transposition has shuffled the letters before the substitution ever sees them. To reverse it, set the tool to Decode, type the same number 23, paste SCYTFPSSUTPGHSFMBSRL, and the original WEHAVETAKENTHEBRIDGE returns. The same number is the only thing the two correspondents need to share.
The number key: one secret, two jobs
The clever heart of the Bazeries cipher is that one number carries the entire key. Spelled out as English words and stripped of repeats, it becomes the keyword that scrambles square 2, so the substitution alphabet changes completely when the number changes. Read instead as a string of digits, the very same number sets the rhythm of the transposition: a key of 23 reverses groups of two and three, while a key of 451 would reverse groups of four, five, and one. A single short number is therefore easy to remember yet sets up two independent mechanisms.
This tool accepts any whole number from 1 to 999999. Type it once and you will see square 2 rebuild itself around the spelled-out keyword, the key letters tinted so you can watch the mixing, while the transposition groups in the working below resize to match the digits. Because the number alone determines everything, it is all that travels inside the share link, never the plaintext itself. A zero among the digits is treated as a full group of ten so the grouping always moves forward, and leading zeros are ignored because the key is simply the number.
Étienne Bazeries, the cryptanalyst
Étienne Bazeries spent decades in and around the French military cipher bureau and earned a reputation as one of the great codebreakers of his age. He is best remembered for solving the Great Cipher of Louis XIV, a nomenclator that had resisted analysis for two centuries, and for his sharp public criticism of the cipher devices of his day. He delighted in showing that systems thought to be unbreakable were not, and he proposed his own cipher both as a teaching example and as a challenge to the cryptographers he sparred with.
It is worth separating two things that share his name. The Bazeries cipher on this page is the pencil-and-paper transposition-and-substitution system driven by a number. The Bazeries cylinder is a different invention, a set of lettered wheels in the family of the Jefferson disk and the later American M-94 device. Both grew out of the same restless mind, but they are mechanically unrelated. Here we focus on the cipher, the one you can work entirely with two squares, a number, and a pencil.
How strong is the Bazeries cipher?
By the standards of its own era the Bazeries cipher was a respectable hand system, precisely because it layers two different ideas. The transposition step moves letters around so that frequency analysis cannot simply read the substitution alphabet off the ciphertext, while the substitution step disguises the identity of each letter so that anagramming alone cannot recover the words. Breaking one stage at a time is much harder when the other stage has already blurred the evidence the analyst would rely on.
Against modern methods, though, it offers no real security. The keyspace is tiny: a short number gives only a handful of possibilities, and even a six-digit number is trivial for a computer to search exhaustively. Once the number is guessed, both stages unwind instantly. The transposition is also self-inverse for a fixed key and the substitution is a fixed monoalphabetic mapping, so the structure gives a determined cryptanalyst several footholds. It is a fascinating historical product cipher, not a tool for protecting anything that matters today.
Is the Bazeries cipher secure?
No. Treat the Bazeries cipher as a piece of cryptographic history and a puzzle, not as protection for sensitive information. Its small key and its neat, reversible structure mean that anyone with a computer, and often anyone with patience and a pencil, can recover the message. It shines as a way to learn how transposition and substitution complement each other, and it is a favourite in puzzle hunts, escape rooms, and capture-the-flag challenges for exactly that reason.
Use this tool to explore how Bazeries combined two simple steps into something cleverer than either, to build and solve puzzles, and to check your work against the standard DCODE to DLSLO vector. For real confidentiality, rely on modern, well-tested algorithms such as AES. Everything here runs locally in your browser, so you can experiment as much as you like without anything you type ever leaving your device.
Frequently asked questions
What is the Bazeries cipher?
How does the number key work?
Why are the two squares built differently?
Can you show a Bazeries cipher example?
How do I decode a Bazeries cipher?
What happens to J and to spaces and punctuation?
Is the Bazeries cipher the same as the Bazeries cylinder?
Who was Étienne Bazeries?
Why reverse groups instead of using a fixed block size?
Is the Bazeries cipher secure?
What numbers can I use as the key?
Is my text uploaded to a server?
Related tools
Keep going with these handy tools