Affine Cipher with Explicit Keys (a, b)
Encrypts text with E(x) = (a·x + b) mod 26, refuses any key a that shares a factor with 26, and prints the modular inverse needed to decrypt.
Ciphertext
—
The affine cipher: multiply and add inside the alphabet
The affine cipher treats each letter as a number from 0 to 25 and applies a first-degree function: multiply by a, add b, take the remainder modulo 26. It generalises the Caesar cipher, which is the case where a equals 1. The interesting part lies in the restriction: not every value of a will do.
Enter the text and the two parameters and the page enciphers, also showing the deciphering formula — which needs the inverse of a modulo 26, the number that undoes the multiplication. With a equal to 5, that inverse is 21, because 5 times 21 is 105, which leaves remainder 1 when divided by 26. That is the number appearing in the inverse formula.
When a is not coprime with 26, the cipher stops being reversible: two different letters land on the same one and information is lost. With a equal to 2, for instance, half the alphabet vanishes from the result. The page refuses those values instead of enciphering silently, and lists the twelve that work: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 and 25.
Frequently asked questions
Why exactly those values of a?
How many keys are there in total?
Does it protect anything?
Related Tools
Bifid Cipher with Custom Key
Encrypts text with the Bifid cipher using a 5x5 Polybius square built from your keyword, merging I and J and interleaving row and column coordinates.
Vernam Cipher (One-Time Pad)
XORs your text byte by byte against a key and prints the ciphertext in hex. A short key repeats, so it is a true one-time pad only if it matches the length.
Playfair Cipher Step by Step
Encrypt/decrypt with Playfair showing the 5×5 matrix, letter pairs and the rule applied to each digram.
Frequency Analysis to Break Ciphers
Count letter, bigram and trigram frequencies in ciphertext and compare with Portuguese/English references.
Vigenère Cipher
Encrypt and decrypt text with the polyalphabetic Vigenère cipher using a keyword. More robust than Caesar by using multiple shifts. Everything in your browser.
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.