Ciphers
Columnar transposition
The text fills rows under a keyword, columns are read out in the keyword's alphabetical order. Whitespace survives the round trip.
- create
- create("columnar")
- family
- Transposition
- options
- --key
- self-inverse
- no
- keyspace
- n! (column permutations)
- try it
- ciphers columnar "ATTACK AT DAWN" --key ZEBRA
The keyword's letters number the columns by alphabetical order, the text fills the grid row by row, and the ciphertext is the columns read in that order. Every character is a cell, spaces too, so decode(encode(x)) is x for any input. key is required.
const columnar = create("columnar");
columnar.encode("ATTACK AT DAWN", { key: "ZEBRA" }).text; // "C TAWT AATNAKD"
columnar.decode("C TAWT AATNAKD", { key: "ZEBRA" }).text; // "ATTACK AT DAWN"
Repeated letters in the key are ordered left to right. This is also the second step of the historical ADFGVX.
Columnar is the one cipher with state. The instance keeps an LRU cache of its last 128 answers and a token bucket of 100 calls a second. Call 101 inside one second throws a CipherError naming the cipher. A cached answer is free and doesn't count.