Affine Cipher
Encode text with the Affine cipher using E(x) = (a·x + b) mod 26. Here uses a=5, b=8 (coprime with 26). Combines multiplicative and additive substitution.
—
Multiply and add, all modulo 26
A modular arithmetic problem set or a first class in classical cryptography: applying E(x) = (5x + 8) mod 26 letter by letter on paper goes wrong somewhere, almost always at the wraparound past Z. Type the word and the result appears immediately. AFFINE CIPHER comes out as IHHWVC SWFRCP, the same example printed in most textbooks. The key is fixed on this page at a=5, b=8, with no field to change it.
The part that trips people up: a must be coprime with 26, otherwise two different letters map to the same output and the cipher stops being reversible. 5 is coprime, so a multiplicative inverse exists, and it is 21, because 5 times 21 is 105, which is 1 modulo 26. Set a=1 and the formula collapses into a Caesar shift. With only 12 valid values for a and 26 for b, the entire key space is 312 combinations, brute forced in milliseconds.
Spaces and punctuation pass through untouched, which keeps word shapes visible. Accented letters also pass through unchanged: ATENÇÃO comes out as IZCVÇÃA, with the Ç and the à giving away the original for free, so type without accents. There is no decrypt mode here, and running the cipher twice does not restore the text: to reverse it use D(y) = 21(y − 8) mod 26. Fine for checking homework, useless as real protection. Everything runs in the browser.
Frequently asked questions
Why is the key fixed at a=5 and b=8?
How do I decrypt an affine cipher message?
Can a be any number?
Related Tools
Pigpen (Masonic) Cipher
Encipher text in Pigpen (the Masonic cipher), drawing all 26 symbols, with the full reference alphabet below.
Encrypt Text
Apply classic ciphers (Caesar, ROT13, Atbash) or Base64. Useful for puzzles, CTFs and testing — do not use for real security.
Trithemius Cipher
Polyalphabetic cipher where letter n is shifted by n positions (similar to Vigenère with key ABCDEF…). Invented by Johannes Trithemius in the 16th century.
ADFGVX Cipher: Substitution Step
Encodes text on a fixed unkeyed 6x6 Polybius square of A-Z and 0-9, turning each character into its ADFGVX pair. No columnar transposition.
Atbash Cipher
Apply the Atbash cipher (A↔Z, B↔Y, C↔X...): each letter is mirrored in the alphabet. Ancient Hebrew cipher used in the Bible. Applying twice returns the original. Everything in your browser.
Vigenère Autokey Cipher Encoder and Decoder
Enciphers or deciphers text with the classic autokey variant, where the plaintext extends the keyword instead of repeating it. Letters A to Z only.