Affine Cipher Solver

Crack an affine cipher by brute force without knowing the key pair. Paste ciphertext, try every valid multiplier a and shift b automatically, compare ranked plaintext candidates, and find the most likely decryption online.

Input
0 chars · 0 bytes
Try:
Result
✓ Tries all valid affine key pairs (a, b) automatically ✓ Multiple alphabets supported ✓ We never store your messages ✓ Processed on our server
Examples
English (a=5, b=8)
Input Ihhwvc swfrcpu cvspyfz cisr lczzcp owzr zoa veqcpws gcyu ivx pcjcil livmeimc fizzcpvu evxcp ivilyuwu
Output a=5, b=8: Affine ciphers encrypt each letter with two numeric keys and reveal language patterns under analysis

Decoded with a=5, b=8: Affine ciphers encrypt each letter with two numeric keys and reveal language patterns under analysis.

English (a=7, b=3)
Input Ksngf mxsrf dggdrvz gsp fufsp udchy vfp edhs nqghc gaf ecdhq gfig fjfstfz hq sfdydkcf mxsj mxs dqdcpzhz
Output a=7, b=3: Brute force attacks try every valid key pair until the plain text emerges in readable form for analysis

Decoded with a=7, b=3: Brute force attacks try every valid key pair until the plain text emerges in readable form for analysis.

English pangram (a=17, b=20)
Input Fjk gwaci lxyeh byv rwqpo ynkx fjk zudm tys ejazk xkutahs czuooacuz zafkxufwxk ulywf uhcakhf jattkh cytko
Output a=17, b=20: The quick brown fox jumps over the lazy dog while reading classical literature about ancient hidden codes

Decoded with a=17, b=20: The quick brown fox jumps over the lazy dog while reading classical literature about ancient hidden codes.

Known plaintext hint (a=11, b=6)
Input Mteot pxgqthyzh fyxpw cetjqli gt gjjqty myk rycgswy ety xyhhyl pgql cgt tglleo hfy wyglcf gtn xetuyl hyzh igmyw lgtmqtu cxyglyl
Output a=11, b=6: Known plaintext helps confirm an affine key because one letter pair can narrow the search and longer text makes ranking clearer

Decoded with a=11, b=6: Known plaintext helps confirm an affine key because one letter pair can narrow the search and longer text makes ranking clearer.

How the affine cipher solver works

An Affine cipher encrypts each letter with the formula E(x) = (a × x + b) mod m, where x is the plaintext letter position, m is the alphabet size, a is the multiplier, and b is the shift. To decrypt correctly, a must be coprime with m so that a modular inverse exists.

This affine cipher solver tests every valid key pair for the selected alphabet. For English, m = 26: there are 12 valid multipliers and 26 shifts, so the complete brute-force search covers 312 possible (a, b) combinations. Other supported alphabets use their own alphabet size and valid multiplier set.

After trying the key space, the tool ranks the best plaintext candidates with language statistics and highlights the most likely key. Spaces, numbers, and punctuation are preserved, so word breaks and sentence structure remain visible while you inspect the results.

When to use affine brute force

Use affine brute force when a message looks like a monoalphabetic substitution cipher and you suspect the Affine formula was used, but the key values a and b are unknown. It is useful for classroom exercises, CTF challenges, escape-room clues, geocaching hints, ARG puzzles, and historical cryptography examples.

Paste the ciphertext, choose the matching alphabet, and run the solver. In English text, common words and patterns such as THE, AND, ING, TION, or repeated letter pairs often make the correct candidate easy to recognize.

If the text was encrypted with a different cipher, the affine solver may still produce interesting partial patterns, but it will not recover a full meaningful plaintext. In that case, compare the result with frequency analysis or try another classical cipher tool.

Reading the ranked results

The solver checks the complete valid key space, but the interface focuses on the strongest candidates instead of forcing you to read hundreds of nearly random decryptions. Each row shows the tested key pair, the decrypted text, and a confidence-style fitness score.

The best-ranked key is a statistical hint, not a mathematical proof. Longer natural-language ciphertext gives the scorer more evidence, while very short clues, names, abbreviations, invented words, or text without spaces can produce several plausible-looking candidates.

When the message is short, read every displayed candidate and use context: expected names, puzzle theme, known words, or a likely phrase can identify the true plaintext even when the automatic score is uncertain.

Tips for cracking affine ciphertext
  • Choose the correct alphabet. English ciphertext should use the English alphabet; accented or language-specific text needs the matching alphabet profile.
  • Keep spacing and punctuation. Non-letter characters are preserved and make readable candidates much easier to spot.
  • Use enough text when possible. A full sentence ranks better than a single word because frequency and bigram patterns become clearer.
  • Check for Caesar as a special case. If the best key has a = 1, the message is effectively a Caesar shift with b as the shift value.
FAQ

The number of valid key pairs (a, b) depends on the alphabet size m. The shift b can be any value from 0 to m - 1, but the multiplier a must be coprime with m. For English (m = 26), there are 12 valid multipliers and 26 shifts, giving 312 possible key pairs. This small key space is why affine brute force is fast.

The condition gcd(a, m) = 1 ensures that the encryption function is reversible. If a and the alphabet size share a divisor, several plaintext letters can map to the same ciphertext letter, so the modular inverse does not exist and decryption becomes ambiguous or impossible.

No. The affine cipher is useful for learning classical cryptography, modular arithmetic, and puzzle solving, but it is not secure. In English it has only 312 valid key pairs, and each plaintext letter always maps to the same ciphertext letter. That makes it vulnerable to brute force, frequency analysis, and known-plaintext attacks.

The best key is the candidate that looks most like natural language according to the solver's scoring. It is a strong hint, especially for full sentences, but it is not a guarantee. Short ciphertext, unusual vocabulary, missing spaces, or puzzle-specific wording can make another displayed candidate the real answer.

A regular affine decoder needs you to know the multiplier a and shift b before decrypting. Affine brute force is a solver: it automatically tries all valid key pairs, ranks the candidate plaintexts, and helps you recover the message when the key is unknown.

Sometimes, yes. Caesar cipher is a special case of the affine cipher where a = 1 and b is the Caesar shift. If a Caesar message is entered here, an affine result with a = 1 may reveal it. For a cleaner all-shifts table, use the dedicated Caesar brute force solver.

The solver uses language statistics, so it needs enough letters to compare patterns reliably. A one-word clue or a short phrase may not contain enough common bigrams and letter frequencies. For short text, review the displayed candidates manually and use any external context from the puzzle or exercise.
Related tools

Affine Cipher

Classical substitution cipher based on modular arithmetic and two numeric keys.

Caesar Brute Force

Caesar cipher solver that tries every shift and highlights the most likely plaintext.

Frequency Analysis

Analyze text frequencies and compare them with known language patterns for cryptanalysis.

Letter Frequency

Online letter frequency analyzer with heatmap, letter counts, and language comparison.

Vigenère Cracker

Automatic Vigenère cipher cracker with key recovery and ranked decryptions.