Ciphers
Tap code
A 5×5 grid tapped as row then column, C and K sharing a cell. Prisoners of war in Vietnam used it through the walls.
- create
- create("tap-code")
- family
- Fractionation
- options
- none
- self-inverse
- no
- keyspace
- 1 (fixed 5×5 grid)
- try it
- ciphers tap-code "HELP"
The Polybius grid again, but the letter dropped is K, sharing a cell with C. Each letter is a row count and a column count, both 1 to 5, digits separated by spaces. Anything that is not a letter is dropped, spaces and punctuation included, and case doesn't matter.
const tap = create("tap-code");
tap.encode("HELP").text; // "2 3 1 5 3 1 3 5"
tap.encode("CK").text; // "1 3 1 3"
tap.decode("1 3").text; // "C"
tap.decode("2 3 1"); // throws, coordinate count must be even
Decoding checks that every coordinate is 1 to 5 and that they come in pairs, and the error names the position of the first bad one. Counting knocks by hand is easy enough to get wrong.