Affine Cipher Demo

EDUCATIONAL DEMONSTRATION ONLY - The Affine cipher uses a linear mathematical function to map each letter. It combines a multiplicative cipher with an additive cipher. The key a must be coprime with 26.

Privacy: this tool processes your data entirely in your browser. Nothing you paste or type is sent to the server.

Must be coprime with 26. Valid: 1,3,5,7,9,11,15,17,19,21,23,25

Additive shift (0-25)

Result

Enter your values and press Calculate — the result appears here.

Worked examples

Encrypt with a=5, b=8

  • text = HELLO
  • a = 5
  • b = 8
  • mode = encrypt

Result: RCLLA

Frequently asked questions

Why must a be coprime with 26?

If a shares a factor with 26, the mapping is not bijective — multiple letters would map to the same output, making decryption impossible.

How many valid keys exist?

There are 12 valid values for a (coprime with 26) × 26 values for b = 312 possible keys. Still trivially breakable by brute force.

💬 Discuss on BestWordz Community

Join the conversation about Cybersecurity, affine cipher, linear cipher on the BestWordz Community forum.

Visit Forum →
Copied!