Tridigital
Tridigital
Three letters to a digit, and the tenth digit is a space.
- Keyspace
- 10! digit orders × 26! alphabets
- Decode
- same options back
- Works on
- A-Z, spaces between words, the rest dropped
- Family
- 2 in mixed alphabet
Options
Access
- Create
create("tridigital") - CLI
ciphers encode tridigital 'THE IDES OF MARCH' --key NOVELCRAFT --second-key DRAGONFLY - Tryplayground with the sample above
- Kinsubstitution
Tridigital turns each letter into one digit. Most digits stand for three letters, so decoding gives you the whole choice in brackets. That's not a failed decode. It's a pattern you can take straight to a word list.
const tridigital = create("tridigital");
const keys = { key: "NOVELCRAFT", secondKey: "DRAGONFLY" };
tridigital.encode("The ides of March", keys).text; // "03095607958910773"
tridigital.decode("03095 60795 89107 73.", keys).text;
// "[AET][GHU][AET] [OIV][DBQ][AET][RCS] [OIV][FKX] [LMZ][AET][RCS][RCS][GHU]"
The block
Tridigital is an ACA cipher type. According to CryptoCrack, ACA member OWLEYES published it in The Cryptogram in July-August 1959.
Both key and secondKey are required. The first sets the digits above a block ten columns wide. Number a ten-letter keyword in alphabetical order, from 1 to 9, then 0 for the tenth letter. Repeated letters are numbered left to right.
The second key builds the alphabet. Drop repeated letters from the keyword, then add the rest of A to Z. DRAGONFLY becomes DRAGONFLYBCEHIJKMPQSTUVWXZ. You can also supply all 26 letters.
Write that alphabet across the first nine columns, row by row. The tenth column stays empty. Its digit separates words.
N O V E L C R A F T
6 7 0 3 5 2 8 1 4 9
D R A G O N F L Y -
B C E H I J K M P -
Q S T U V W X Z - -
There are 26 letters in 27 cells, so one letter column has only two. Each letter becomes the digit above its column. A space becomes 9 here.
You can also give key as the ten digits in any order. They're used as they stand. key: "6703528149" makes the same block as NOVELCRAFT. That's useful with sites that number differently. kryptografie.de counts from 0, so pass its digits as they stand.
What does decoding give you?
A digit can't tell you which letter was meant. The decoder returns its whole column, top row first, as a regex character class. The separator becomes a space. Picking a letter after that is a guess.
Try grep -xE '[AET][GHU][AET]' words.txt. It finds THE, but also AGE, AHA and TUT. All four fit. For a candidate sentence, new RegExp(`^${decoded}$`) works the same way.
Is that good security? No. Tridigital is hopeless as real crypto, but it's a good puzzle. A digit count finds the separator, word lengths fall out, and solvers fit words from a list.
What it skips
Encoding uppercases the text, keeps A to Z, and splits words on whitespace. Punctuation and digits are dropped. The ciphertext comes out as one run of digits.
Decoding reads only digits. Groups of five and a final period, as in the example above, are fine.
Checked against
The ACA example, both ways. CryptoCrack's TRAMPOLINE and OSCARWILDE example. Two examples from The Black Chamber blog in 2020: SUNDAY and teacher.
Errors and analysis
A missing key or secondKey raises MissingOptionError. A key that isn't ten ASCII letters or the digits 0 to 9 once each raises InvalidOptionError. So does a secondKey with no ASCII letter. Decoding text with no digits raises CipherError.