Ciphers
Alberti
A keyed inner disk against a fixed outer alphabet, turned one step after every period letters. Simplified on purpose, so it is reproducible.
- create
- create("alberti")
- family
- Polyalphabetic
- options
- --key --period
- self-inverse
- no
- keyspace
- fixed
- try it
- ciphers alberti "ATTACK AT DAWN" --key ALBERTI --period 4
Alberti's disk of 1467 had a fixed outer ring and a movable inner ring, and the operator turned the inner ring by agreement. That agreement is the problem - two implementations, two answers. So this one fixes it: the inner disk is the keyword with duplicate letters removed, then the rest of the alphabet, and it rotates one position after every period Latin letters. key and period are both required, period a positive integer.
const alberti = create("alberti");
alberti.encode("ATTACK AT DAWN", { key: "ALBERTI", period: 4 }).text; // "ASSAEH LU TBYN"
alberti.decode("ASSAEH LU TBYN", { key: "ALBERTI", period: 4 }).text; // "ATTACK AT DAWN"
alberti.encode("AAAA A", { key: "KEY", period: 4 }).text; // "KKKK E", the disk turned after four
Only ASCII letters count toward the period and the rotation, anything else passes through. This is not a historical simulation. It's a disk with a clock, which is what a puzzle setter usually means when they write "Alberti".