About this tool
The Affine Cipher Encoder / Decoder is a free, in-browser tool for the monoalphabetic cipher built on modular arithmetic. Letters A–Z are numbered 0–25 and each is transformed by the linear function E(x) = (a·x + b) mod 26, where a and b are the two key values. Decoding inverts this with D(y) = a⁻¹·(y − b) mod 26, where a⁻¹ is the modular multiplicative inverse of a modulo 26.
For the cipher to be reversible, the multiplier a must be coprime with 26 — that is, gcd(a, 26) = 1. The twelve valid choices are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25; any other value would map two different letters to the same output and cannot be decoded, so the tool rejects it with a clear message. The additive key b may be any value 0–25. Everything is computed locally in your browser, so nothing you type leaves your device.
Case is preserved and non-letters pass through unchanged. The Affine cipher generalises simpler classical ciphers: setting a = 1 reduces it to a Caesar shift of b, and a = 25, b = 25 reproduces the Atbash cipher. It is a staple of discrete-mathematics and number-theory courses because it makes the ideas of coprimality and modular inverses concrete, and it shows up regularly in CTF puzzles and tools such as CyberChef.