All operations

Affine cipher

Multiply the letter's position by one key, add a second, keep the remainder.

The two keys

Number the letters from zero. Each one moves to position (a * i + b) mod 26. The keys loaded above are a = 5 and b = 8, so A sits at 0, lands on 8 and comes out as I, while B lands on 13 and comes out as N. Consecutive plaintext letters land five apart in the ciphertext, wrapping at 26, and every position is filled exactly once by the time the alphabet runs out. Case survives and non-letters stay put, which is why the 13 in the loaded sentence is still 13 in the output.

Why the multiplier is restricted

Set a to 2 and the cipher stops working. Doubling a number and taking the remainder mod 26 only ever yields an even result, so thirteen letters become unreachable and each of the remaining thirteen has two sources: 2 * (i + 13) is 2i + 26, which reduces straight back to 2i. A and N produce the same ciphertext letter, as do B and O, and every other pair thirteen apart. No decryption rule exists, because the information is already gone.

The multiplier has to share no factor with 26. Since 26 factors into 2 and 13, that rules out every even number and 13 itself, leaving twelve legal values: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 and 25. Anything else is refused here with that list, rather than producing output nobody can undo.

Caesar and Atbash live inside it

Fix a at 1 and the multiplication does nothing, leaving i + b. That is the Caesar cipher, and b = 13 makes it ROT13. Set both keys to 25 and 25i + 25 reduces to 25 - i, which is Atbash. Both are affine keys with one dial glued down.

How it breaks

Twelve multipliers by twenty-six shifts is 312 keys, and one of those, a = 1 with b = 0, leaves the text alone. A machine works through the other 311 faster than the page repaints. Frequency analysis is quicker still, since one mapping covers the whole message and E and T give themselves up in any text long enough to count. Two confirmed letter pairs give two linear equations in a and b, which solve for the key directly.

Alphabetical substitution is the general case, reaching any of the 26 factorial rearrangements where the affine cipher reaches 312. Vigenere goes after the real weakness by changing the shift as it moves through the text.