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
Auto Solve Options
You can decode (decrypt) or encode (encrypt) your message with your key. If you don't have any key, you can try to auto solve (break) your cipher.
- Language: The language determines the letters and statistics used for decoding, encoding and auto solving.
- Max Results: This is the maximum number of results you will get from auto solving.
- Spacing Mode: This is about the spaces (word breaks) in the text. In most cases it should be set to Automatic. In case a specific letter (for instance X) is used as word separator, set it to Substitute.
Auto Solve results
Still not seeing the correct result? Then try experimenting with the Auto Solve settings 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:
kxzaan dzve wcx dlzkxlkfb nfp fpjcw wf sx zdcztxe fq nfpkdxaq qfk sxvmj dplc z cptspj v zt v lxkwzvman zt zmdbxkxe wcx avwwax tzm dfkkfbqpaan spw vw bzd wcx fman wcvmj v lfpae ef
See also: Code-Breaking overview | Adfgvx cipher | Adfgx cipher | Atbash cipher | Baconian cipher | Beaufort cipher | Bifid cipher | Caesar cipher | 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 | Route transposition | Trifid cipher | Variant beaufort cipher | Vigenere cipher