Encrypt or decrypt
E(x) = (a*x + b) mod 26. The multiplier a must be coprime to 26.
The result appears below. Case is preserved; other characters pass through.
Encrypt and decrypt with the affine cipher. Set multipliers a and b; each letter maps through E(x) = (ax + b) mod 26.
E(x) = (a*x + b) mod 26. The multiplier a must be coprime to 26.
The result appears below. Case is preserved; other characters pass through.
The affine cipher encrypts each letter x (A=0 through Z=25) as E(x) = (a*x + b) mod 26. The multiplier a must be coprime to 26 (one of 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25); otherwise several letters collide and decryption is impossible. Decryption uses the modular inverse of a.
Only 12 valid values of a times 26 values of b gives 312 possible keys, brute-forced in milliseconds. Frequency analysis also breaks it directly since it is monoalphabetic. The affine cipher is a teaching tool for modular arithmetic, not a security mechanism.