Affine Cipher Decoder - Automatic Brute Force Decryption

Decode Affine cipher without knowing the key by testing all 312 possible combinations

Ciphertext Input

How It Works

This decoder tests all 312 possible key combinations (12 valid 'a' values × 26 'b' values) and ranks results using frequency analysis. The plaintext with letter frequencies closest to standard English is most likely correct.

How to Decode the Affine Cipher

The affine cipher decoder is designed to automatically crack affine-encrypted messages without knowing the original keys. Since the affine cipher only has 312 possible key combinations (12 valid A values × 26 B values), a brute-force approach is highly effective.

Our decoder tests every possible key pair and uses frequency analysis to rank the results, presenting the most likely plaintext solutions first.

Brute Force Decryption Method

The brute-force approach for breaking the affine cipher works as follows:

  1. Generate all key combinations - Test all 12 valid A values (1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25) with all 26 B values
  2. Decrypt with each key pair - Apply the decryption formula D(y) = a⁻¹(y - b) mod 26
  3. Score each result - Use frequency analysis to evaluate how closely the output matches English text
  4. Rank and display - Present results sorted by likelihood score

This process completes in milliseconds on modern computers, making the affine cipher trivially breakable.

Frequency Analysis Scoring

Our affine cipher decoder uses English letter frequency analysis to identify correct decryptions:

Expected English Letter Frequencies:

  • Most common: E (12.7%), T (9.1%), A (8.2%), O (7.5%), I (7.0%)
  • Least common: Z (0.07%), Q (0.10%), X (0.15%), J (0.15%)

The decoder calculates a chi-squared statistic comparing the decrypted text's letter distribution against expected English frequencies. Lower scores indicate better matches to natural English text.

Using the Affine Decoder Tool

  1. Paste your ciphertext into the input field
  2. Click Decode to start the brute-force analysis
  3. Review ranked results - The most likely solutions appear first
  4. Examine top matches - Check if the plaintext makes sense
  5. Note the discovered keys - The tool shows which A and B values produced each result

For learning how the encryption works, visit our main Affine Cipher tool. To understand key mathematics, see our Calculator.

Frequently Asked Questions

How long does it take to crack an affine cipher?

With only 312 possible key combinations, our decoder cracks affine ciphers almost instantly. The entire brute-force process typically completes in under 100 milliseconds.

Can the affine cipher decoder work on short messages?

Yes, but accuracy decreases with shorter texts. Frequency analysis works best with messages of 50+ characters. For very short texts, you may need to manually review multiple results.

What if the plaintext isn't in English?

Our decoder is optimized for English text. For other languages, the frequency analysis may not rank the correct solution first. You can still find the right answer by reviewing all 312 results.

How is this different from the Caesar cipher decoder?

The Caesar cipher decoder only tests 26 shift values. The affine decoder tests 312 combinations because it must find both the multiplicative key (A) and additive key (B).