ToolPuma Logo

Affine Cipher

Encrypt or decrypt text with the affine substitution cipher.

Note: The affine cipher uses E(x) = (a·x + b) mod 26. The multiplier "a" must be coprime with 26 (choose from 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25) or an error is shown.

What Is a Affine Cipher?

The Affine Cipher tool encrypts and decrypts text with the formula E(x) = (a·x + b) mod 26, a combination of a multiplication and a shift. The multiplier 'a' must be coprime with 26 so that decryption is possible. This free online tool is useful for Affine cipher, Affine cipher calculator, Affine encrypt decrypt. Common use cases include modular arithmetic, classical cryptography, puzzles, and cryptography education. It is designed for quick browser-based hashing, encoding, decoding, encryption testing, checksum comparison, identifier generation, and cryptography education. For production security, follow the algorithm's current standards, key-management requirements, and application-specific security guidance.

How to Use This Affine Cipher

  1. 1
    Choose the directionSelect Encrypt or Decrypt where the tool provides both operations.
  2. 2
    Enter the settingsProvide the shift, keyword, rails, or other cipher parameters.
  3. 3
    Enter the textPaste the plaintext or ciphertext into the input field.
  4. 4
    Run the transformationThe tool applies the selected classical cipher locally.
  5. 5
    Review the resultCopy the transformed text for your puzzle, experiment, or educational exercise.

Frequently Asked Questions

Decryption needs a modular inverse of 'a'. That inverse exists only when 'a' and 26 share no common factor, so valid choices are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25.
Very weak — there are only 12 × 26 = 312 possible keys, so it is easily brute-forced. It is useful for teaching modular arithmetic.