Affine Cipher

Rclla, Pivmxaq!
Transformed locally in your browser. Each letter at position x maps to (a·x + b) mod 26 while case is preserved; digits, punctuation, and spaces pass through unchanged. The multiplier a must be coprime with 26 so the cipher stays reversible.

Encode text with an affine transform

The affine cipher multiplies each letter's position by a and adds a shift b before wrapping mod 26. It generalizes the Caesar cipher (a = 1) and Atbash (a = 25, b = 25). Only a values coprime with 26 keep the mapping invertible.

When to use this tool

Reach for the affine cipher when a puzzle, CTF challenge, or intro-cryptography lesson calls for the multiplicative-plus-shift substitution defined by E(x) = (a·x + b) mod 26. It generalizes the rest of the classical family — the Caesar cipher is the special case a = 1, and Atbash is a = 25, b = 25 — so it is the natural next step once shift-only and keyword ciphers feel familiar.

Privacy and limitations

Everything runs locally in your browser; nothing is sent anywhere. This is a classical cipher, not real encryption — it only transforms A–Z and a–z, leaves digits, symbols, and non-Latin characters untouched, and requires the multiplier a to be coprime with 26 so the mapping stays reversible. Use the encode/decode toggle to switch directions, since the transform is not self-inverse.