Ciphers

Bacon's cipher

Five A or B per letter, no separators. The 26-letter table by default, Bacon's own 24-letter one with I/J and U/V shared on request.
IDbacon29 / 72classical · fractionation
Cipher / Fractionation

Bacon's Cipher

Five A or B per letter.

Keyspace
2
Decode
same options back
Works on
A-Z, the rest dropped
Family
10 in fractionation
required 0 / 1

Options

lettersnumber
default 26
26 codes every letter; 24 is Bacon's own table with I/J and U/V shared

Access

Createcreate("bacon")
CLIciphers encode bacon SECRET
Tryplayground with the sample above
Kinpolybius, nihilist, morse, fractionated-morse +5

Francis Bacon's cipher writes each letter as five symbols from a two-letter alphabet, originally to hide a message in the italics of an innocent text. His table has 24 letters, I and J on one code, U and V on another. The default here is the 26-letter version - A is AAAAA, B is AAAAB, Z is BBAAB - so the round trip is exact. letters: 24 switches to Bacon's table. No separators in the output. Decoding reads any A and B, ignores everything else, takes them five at a time. When they don't come out even, it says so instead of dropping the rest. Text without a single A or B is an error too, not an empty answer.

ts
const bacon = create("bacon");
bacon.encode("A").text; // "AAAAA"
bacon.encode("HI").text; // "AABBBABAAA"
bacon.decode("AABBB ABAAA").text; // "HI"
bacon.decode("AABBB ABAAA AB"); // CipherError: Invalid Bacon code: 12 letters A and B, not a multiple of five
bacon.encode("KNIGHT", { letters: 24 }).text; // "ABAABABBAAABAAAAABBAAABBBBAABA"
bacon.decode("ABAABABBAAABAAAAABBAAABBBBAABA", { letters: 24 }).text; // "KNIGHT"
bacon.decode("ABAABABBAAABAAAAABBAAABBBBAABA").text; // "JMIGHS", the same groups on the 26-letter table

The two tables agree from A to I and drift by one code from K on, by two from W, so a 24-letter puzzle decoded on the 26-letter table comes out wrong from the first K, not just at J and V. Wikipedia's example encodes steganography on the 24-letter table, baaab baaba aabaa aabba aaaaa abbaa abbab aabba baaaa aaaaa abbba aabbb babba, and that's the vector in the test suite. On the 24-letter table J encodes as I and V as U, and decoding gives back I and U. A group past the end of the table, BBAAA and up on 24 letters, BBABA and up on 26, decodes to ?.