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

## Affine Cipher Tool

You must enter the message.

🔑×
You must enter the encryption key.
🔑+
You must enter the encryption key.
🌎

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

Not seeing the correct result? Try Auto Solve or use the Cipher Identifier Tool.

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

ij omq jsjs jpmj gmrk rsxsjpa nmcwp mzr qmvkr pkx dxsg wxsoizw mq wxma mq pkx sjpkx qcxxsczrizwq jsjs omq zsj wxma pk omq m nijjnk fnmyu rsw oijp nszw qinua pmix mzr qgmnn fnmyu kakq jpmj joizunkr gkxxina sz kijpkx qirk sd piq dczza okk zsqk