Encode a word
Hello
AABBB AABAA ABABB ABABB ABBBA
H is letter 7 (00111 in binary), so it becomes AABBB.
Encode letters as groups of five A/B symbols, or hide a secret message in the capital letters of an ordinary sentence. Supports the original 24-letter and the modern 26-letter alphabet.
A/B groups, 0/1 groups, or Hidden in text, which writes the message as lowercase and capital letters of your Cover text.Hello
AABBB AABAA ABABB ABABB ABBBA
H is letter 7 (00111 in binary), so it becomes AABBB.
AABBB AABAA ABABB ABABB ABBBA
HELLO
Spaces between groups are optional when decoding.
HI
thEBA cOnci pher hides secrets
Lowercase letters mean A and capitals mean B: thEBA cOnci reads AABBB ABAAA, which is H I.
thEBA cOnci pher hides secrets
HI
Trailing all-lowercase groups after the message are ignored.
The Bacon cipher (or Baconian cipher) writes every letter as a group of five symbols that are each either A or B. It was devised by Francis Bacon around 1605. Its real strength is not the code itself but where it can hide: the A and B can be any two things that look alike, such as two fonts, lowercase and capital letters, or bold and normal text. That makes it an early example of steganography, hiding the very existence of a message.
Each letter's position (starting at 0) is written in binary with five digits, with A for 0 and B for 1. In the modern 26-letter version:
| Letter | Code | Letter | Code | Letter | Code |
|---|---|---|---|---|---|
| A | AAAAA | J | ABAAB | S | BAABA |
| B | AAAAB | K | ABABA | T | BAABB |
| C | AAABA | L | ABABB | U | BABAA |
| D | AAABB | M | ABBAA | V | BABAB |
| E | AABAA | N | ABBAB | W | BABBA |
| F | AABAB | O | ABBBA | X | BABBB |
| G | AABBA | P | ABBBB | Y | BBAAA |
| H | AABBB | Q | BAAAA | Z | BBAAB |
| I | ABAAA | R | BAAAB |
Bacon's original alphabet had only 24 letters: I and J shared a code, and so did U and V. Choose 24 letters to match old texts and many puzzle books.
Write any sentence, then use its letters as carriers: a lowercase letter means A and a capital letter means B. Each group of five letters carries one hidden letter. With the cover text "the bacon cipher hides secrets", the message HI (AABBB ABAAA) becomes thEBA cOnci pher hides secrets. Spaces and punctuation are ignored when reading, and the cover needs five letters for every letter of the secret.
Bacon himself proposed using two slightly different typefaces, so the hidden message would be invisible to anyone not looking for it.
Hidden is not the same as secure. Once someone suspects a Bacon cipher, it is easy to read. It is perfect for puzzles and games.
const encode = (text) => [...text.toUpperCase().replace(/[^A-Z]/g, '')] .map((c) => (c.charCodeAt(0) - 65).toString(2).padStart(5, '0').replace(/0/g, 'A').replace(/1/g, 'B')) .join(' '); const decode = (code) => code.replace(/[^AB]/gi, '').toUpperCase().match(/.{5}/g) .map((g) => String.fromCharCode(65 + parseInt(g.replace(/A/g, '0').replace(/B/g, '1'), 2))) .join(''); encode('Hello'); // "AABBB AABAA ABABB ABABB ABBBA"The decoded text is almost right but some letters are off by one
The message uses the other alphabet. Switch between 26 letters and 24 letters (where I = J and U = V).
A hidden-text message decodes with extra letters
The cover text has stray capitals, such as at the start of a sentence or in names. Hidden text must only use capitals for B. Write the cover in lowercase before encoding.
Some letters decode as ?
A group of five is not a valid code (for example BBBBB in the 26-letter alphabet), or a symbol is missing and the groups are misaligned.
Each letter becomes five symbols, each A or B, like a 5-bit binary number. H, for example, is AABBB. The A and B can then be hidden as two different styles of letters.
Bacon's original version merged I with J and U with V, giving 24 letters. The modern version gives every letter its own code.
Choose Encode and set Output to Hidden in text, then type your secret and a cover sentence. Lowercase letters stand for A and capitals for B.
No. Everything runs in your browser.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.