5 Shift: 8 AFFINE CIPHER
IHHWVC SWFRCP
Classic English Affine example with multiplier 5 and shift 8.
Encrypt and decrypt text with the Affine cipher using two numeric keys: multiplier a and shift b. Learn how modular arithmetic creates a classical substitution cipher.
5 Shift: 8 AFFINE CIPHER
IHHWVC SWFRCP
Classic English Affine example with multiplier 5 and shift 8.
5 Shift: 8 IHHWVC SWFRCP
AFFINE CIPHER
The same numeric keys restore the plaintext.
7 Shift: 3 HELLO WORLD
AFCCX BXSCY
Changing multiplier a and shift b creates a different substitution alphabet.
5 Shift: 8 MEET AT 10:00!
QCCZ IZ 10:00!
Only alphabet characters are encrypted. Spaces, numbers, punctuation marks, and other symbols remain unchanged.
The Affine cipher is a classical monoalphabetic substitution cipher that transforms each letter using a mathematical formula. Every letter is first converted to a number, then encrypted with E(x) = (a × x + b) mod m, where x is the letter position and m is the alphabet size.
The key consists of two numbers. The multiplier a changes how letter positions are scaled, while the shift b moves the result through the alphabet. Together they create a fixed substitution alphabet.
To decrypt a message, the value of a must have a modular inverse. This is only possible when a is coprime with the alphabet size. Spaces, digits, and punctuation are preserved unchanged.
The Affine cipher uses two numeric parameters: a and b. The value a is the multiplier, and b is the shift. Both values affect the final substitution alphabet.
Not every multiplier is valid. For English with 26 letters, a must be coprime with 26. Valid examples include 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25. If a is not valid, decryption cannot reliably restore the original message.
The Caesar cipher uses only one operation: a fixed shift. The Affine cipher extends this idea by combining multiplication and addition modulo the alphabet size.
If a = 1, the Affine cipher behaves like a Caesar cipher with shift b. When a is another valid multiplier, the substitution pattern becomes less obvious while still remaining a monoalphabetic substitution cipher.
The Affine cipher is stronger than a basic Caesar shift because it has more possible keys, but it is still weak by modern cryptographic standards.
Because each plaintext letter always maps to the same ciphertext letter, the cipher remains vulnerable to frequency analysis and brute-force testing of possible key pairs. Today it is mainly useful for education, puzzles, and learning modular arithmetic in cryptography.
Classic letter-shift cipher with custom shift values.
Classic digraph substitution cipher with keyword matrix encryption.
Classical reciprocal cipher based on a keyword.
Vigenere-style classical cipher that uses a numeric key.
Keyword-based polyalphabetic encryption and decryption.
XOR-based Vernam encryption with Base64 output.