# Affine Cipher

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.

-> Try your skills on Boxentriq's puzzles. Click here. <-

## Affine Cipher Tool

#### Auto Solve Options

### Instructions

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.

##### Settings

**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.

### Results

### Auto Solve results

Score | Key | Text |
---|

Still not seeing the correct result? Then try experimenting with the Auto Solve settings or use the Cipher Identifier Tool.

## Features

- 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:

bk icc bhc okkj gabqh ghk pufci hcpc ihc erigcpcj gaff sku bemc yc bk hcp fcb yc henc skup reyc erj a gaff eim ofarje av ihc gaff pcqcanc sku

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