Bacon’s cipher: chart and steganography
Bacon’s cipher writes each letter as a group of five characters in which only two appear: a and b. A is aaaaa, B is aaaab, C is aaaba and so on; you will find the whole chart below. It also goes by the names Baconian alphabet, a-b cipher or binary cipher. This is what the word “ahoj” (Czech for “hello”) looks like:
| A | H | O | J |
|---|---|---|---|
| aaaaa | aabbb | abbba | abaab |
The encrypted “ahoj” therefore reads aaaaa aabbb abbba abaab. But the real trick comes now: if two different characters are enough, a message can be hidden in anything that comes in two kinds. Instead of a and b, ordinary and bold type will do, or capital and small letters, or light and dark pebbles or beads of two colours. Anyone who does not know about the message sees only an ordinary sentence or a bracelet. Hiding things like this is called steganography.
Bacon’s cipher converter
Type some text and the converter rewrites it as groups of a and b. It separates letters with a space and words with a slash. It drops accents (č is written as c) and leaves out digits and punctuation. When deciphering, it looks only at the letters a and b (capital and small), skips the other characters and reads in groups of five. There are 32 groups but only 26 letters, and the converter shows a code that stands for no letter as #. It cannot hide a message in a sentence with bold type; you can do that yourself following the instructions below.
The Baconian alphabet chart
All 26 letters of the international alphabet have a code of their own:
| letter | code | letter | code |
|---|---|---|---|
| A | aaaaa | N | abbab |
| B | aaaab | O | abbba |
| C | aaaba | P | abbbb |
| D | aaabb | Q | baaaa |
| E | aabaa | R | baaab |
| F | aabab | S | baaba |
| G | aabba | T | baabb |
| H | aabbb | U | babaa |
| I | abaaa | V | babab |
| J | abaab | W | babba |
| K | ababa | X | babbb |
| L | ababb | Y | bbaaa |
| M | abbaa | Z | bbaab |
You do not have to learn the chart, because the codes follow a rule. The last character changes with every letter (a, b, a, b…), the one before it every two letters (a, a, b, b…), the middle one every four, and so on. When there is nowhere left to add to the last place, the b goes back to a and the character before it changes: after aaabb (D) comes aabaa (E). Be careful: older charts on the internet have only 24 letters and differ from ours from J onwards (more in the history at the end). So agree with your friends which one you are using.
Steganography: a message hidden in an ordinary sentence
A cipher hides what a message says. Whoever intercepts it knows that something is being concealed, but cannot understand it. Steganography (from the Greek for “hidden writing”) hides the very existence of a message. The Baconian alphabet can do both: it rewrites the message into a and b, and that can then be hidden in an innocent sentence. (More about the difference in the article Cryptography.)
Let’s hide the distress call SOS in the sentence “Dnes bude táborák” (Czech for “there will be a campfire tonight”).
Step one: we convert the secret message using the chart. S is baaba, O is abbba, S again baaba. That is 15 characters in all, so the carrier sentence needs at least 15 letters (spaces do not count, and á is a letter too). “Dnes bude táborák” has exactly that many. If it were longer, we would write the remaining letters normally. The receiver then reads until nonsense comes out, or you agree in advance that the message ends with, say, an X.
Step two: we divide the letters of the carrier sentence into groups of five and assign the first character of the secret message to the first letter of the sentence, the second to the second, and so on:
| letters of the sentence | characters | letter |
|---|---|---|
| D N E S B | b a a b a | S |
| U D E T Á | a b b b a | O |
| B O R Á K | b a a b a | S |
Step three: we write the letters that go with b in bold and the others normally:
Dnes bude táborák
For checking, here it is once more with a or b under each letter:
| D | n | e | s | b | u | d |
|---|---|---|---|---|---|---|
| b | a | a | b | a | a | b |
| e | t | á | b | o | r | á | k |
|---|---|---|---|---|---|---|---|
| b | b | a | b | a | a | b | a |
The sender and receiver must agree in advance that a message is hidden in the sentence and which type means a and which means b. The receiver then reverses the process. Ordinary type is a, bold is b. They receive baaba abbba baaba, divide it into groups of five and find S, O, S in the chart. Anyone who does not know sees only a sentence where the printing has gone a little wonky.
Where you have no bold type, for example in a text message or a handwritten note, capital and small letters will do (a capital is b): DneS buDE TáBorÁk. The converter cannot read such a sentence directly, and you have to write out the a and b yourself. That is more conspicuous. Bacon himself therefore used two typefaces that differ from each other only slightly. The price of being inconspicuous is length: the carrier text must have five times as many letters as the secret message.
Why exactly five characters
One place where we may write a or b gives 2 possibilities. Two places give 2 · 2 = 4: aa, ab, ba, bb. Each further place doubles the number, because everything so far can be completed once with a and once with b. Five places therefore give
different groups. That is enough for 26 letters, and six codes are even left over, which is why the converter writes them out as #. Four places would not be enough, since 24 = 16 is fewer than 26. You can find more about working with powers in the article Powers.
The next paragraph is for the curious and you can skip it. If we write a zero instead of a and a one instead of b, the code is an ordinary number in the binary system: the position of the letter in the alphabet, counted from zero. A is 0 = 00000, B is 1 = 00001 and H, the eighth letter, has position 7 = 00111. Let’s check: in the binary system the places from the right have values 1, 2, 4, 8 and 16, so
Unlike Morse code, whose codes have different lengths (E is a single dot, J is a dot and three dashes) and which needs a pause between letters, the Baconian alphabet has all its codes the same length: a letter ends after every five characters. That is exactly why it can be hidden in a continuous sentence.
How to break Bacon’s cipher
The chart is public and there is no key. Anyone who sees a string of a’s and b’s whose length is a multiple of five immediately suspects what it is and reads the message. With a hidden message, the hard part is noticing it: you have to realise that it is there at all. But once you see two kinds of letters in a sentence, it is enough to try one as a and the other as b, and if nonsense comes out, swap them. If the sender had shuffled the letters in the chart, frequency analysis helps, just as with the substitution cipher.
A short history
The system was described by the English philosopher and statesman Francis Bacon in 1623 in his work De Augmentis Scientiarum. His alphabet had only 24 letters, because I and J, and also U and V, counted as one letter at the time and shared a code. That is why his codes differ from today’s from J onwards. Some enthusiasts searched for hidden Baconian messages in the first editions of Shakespeare’s plays; experts reject these theories.
At camp you can thread a message from beads of two colours, lay it out from light and dark pebbles along a path or draw it with arrows of two colours on trees. Players only need to know that you count in fives and which kind means a and which means b.