The Affine cipher is a monoalphabetic substitution cipher, where each letter in the alphabet is mapped to another letter through a simple mathematical formula: (ax + b) mod 26. The number 26 represents the length of the alphabet and will be different for different languages. The Affine cipher can be broken using the standard statistical methods for monoalphabetic substitution ciphers.
Affine Cipher Tool
Knowing the encryption key
Not knowing the key
Still not seeing the correct result? Then try experimenting with the Auto Decrypt options or use the Cipher Identifier Tool.
- The Affine cipher is a form of monoalphabetic substitution cipher.
- The translation alphabet is determined by mapping each letter through the formula (ax + b) mod m, where m is the number of letters in the alphabet and a and b are the secret keys of the cipher. To ensure that no two letters are mapped to the same letter, a and m must be coprime. That is, they mustn't have any common divisors. For the English alphabet, where m = 26, this means a cannot be 2, 4, 6, 8 (any even number) or 13.
- If a = 1, the Affine cipher is equivalent of a Caesar cipher. In the special case a = 1 and b = 0, it performs no encryption.
- To decrypt, a is replaced by the modular multiplicative inverse of itself, and b is replaced by m - b.
- To improve obfuscation, spaces can be removed or replaced with a character, such as X, in the plaintext before encryption.
- An Affine cipher can be solved through frequency analysis.
Affine cipher, and variants of it, are occasionally used in crypto puzzles and logic puzzles.
Sample Keyed Caesar Cipher
Code-breaking is not only fun, but also a very good exercise for your brain and cognitive skills. Why don’t you try breaking this example cipher:
fie zfap cna ea zi typh fan ypusynah zfa mynd zfcz eydd va acgq nabdyah zfa wcp tin efap gfa kpieg qis cna yp zfa oispznq it zfa eypkyag gfa eydd typh qis cph wcka qis cdd fan gdclag
See also: Code-Breaking overview | Adfgvx cipher | Adfgx cipher | Atbash cipher | Beaufort cipher | Bifid cipher | Caesar cipher | Cipher identifier | Columnar transposition | Cryptogram | Double transposition | Enigma machine | Four-square cipher | Gronsfeld cipher | Keyed caesar cipher | One-time pad | Pigpen cipher | Playfair cipher | Rail fence cipher | Rot13 | Trifid cipher | Variant beaufort cipher | Vigenere cipher