Encrypt or decrypt text with the affine cipher using a and b modulo 26. Requires a coprime to 26 and preserves letter case and punctuation.
0 / 10,000 characters
Each example lists a, b, direction, and notes. Outputs are deterministic for the given parameters; punctuation and case are preserved where shown.
English
HELLO
Translation
RCLLA
Forward conversion with default settings
English
WORLD
Translation
OAPLX
Forward conversion with default settings
English
GOOD DAY
Translation
MAAX XIY
Forward conversion with default settings
English
SECRET
Translation
UCSPCZ
Forward conversion with default settings
English
MEET ME
Translation
QCCZ QC
Forward conversion with default settings
English
FRIEND
Translation
HPWCVX
Forward conversion with default settings
An affine cipher is only reversible when a is coprime to 26. If a shares a factor with 26, two different plaintext letters can encrypt to the same ciphertext letter, so the original text cannot be recovered uniquely. The tool rejects such values.

The tool applies the affine map only to letters. Uppercase and lowercase letters are transformed separately, so case is preserved. Spaces, punctuation, digits, and symbols pass through unchanged. This makes short messages easier to read and avoids losing formatting.

| Input | Rule | Result |
|---|---|---|
| a = 5 | gcd(5, 26) = 1 | Valid |
| a = 2 | gcd(2, 26) = 2 | Not valid |
| a = 13 | gcd(13, 26) = 13 | Not valid |
For the affine cipher to be reversible, a must be coprime to 26, meaning gcd(a,26)=1. The valid values are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25. Other values cause collisions, so different plaintext letters can map to the same ciphertext letter.
Encryption maps a letter value x to (a x + b) mod 26. Decryption uses the modular inverse of a modulo 26, written a⁻¹, and maps y to a⁻¹ (y − b) mod 26. For a = 5, the inverse is 21 because 5 × 21 = 105 ≡ 1 mod 26.
| Input | Rule | Result |
|---|---|---|
| HELLO | a = 3, b = 7, encrypt | CTOOX |
| CTOOX | a = 3, b = 7, decrypt | HELLO |
| IHHWVC | a = 5, b = 8, decrypt | AFFINE |
When a puzzle gives a ciphertext and hints like a = 5, b = 8, enter the text and choose decrypt. The tool maps each letter back to plaintext while leaving spaces and punctuation in place, so you can read the original message without manual table lookups.

Show how encryption uses (a x + b) mod 26 and decryption uses a modular inverse. Change a and b to demonstrate valid and invalid multipliers. Students can see immediately why a must be coprime to 26 and how case and punctuation survive the mapping.

Turn a short phrase into an affine cipher before sharing it with a friend who knows the a and b values. Because the tool preserves spaces and punctuation, the result stays readable as a puzzle. It works locally, so no text leaves your browser.

Before using a set of a and b values in code or a puzzle, test them here. Enter sample text such as ABC and see the mapping. If a is not coprime to 26, the tool reports an error instead of producing ambiguous output.

Explore the Affine Cipher Translator features and supported options.
Enter text, choose a and b, and select encrypt or decrypt. The affine map runs in your browser with modulo 26 arithmetic. No login, credits, or network request is needed for this local tool.
The tool checks whether a is coprime to 26 before transforming text. Valid values include 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25. Invalid values produce a clear error message.
Letters are shifted according to their alphabet position, with uppercase and lowercase handled separately. Spaces, commas, periods, digits, and other non-letter characters remain unchanged, so the output keeps the original layout and readable structure.
After generating a result, use the copy button to place it on your clipboard, download it as a text file, load the sample to see how the cipher works, or reset the fields to start a new message.
Shift letters by 0–25 positions; preserve case and punctuation.
ROT13 TranslatorApply the reversible 13-position Latin letter substitution.
Tap Code TranslatorUse the 5×5 C/K merged grid. Encode letters as row.column pairs with / between words; decode dot-tap pairs or coordinates.
Bacon Cipher TranslatorUse five A/B symbols per letter; select modern 26-letter or historical 24-letter I/J and U/V merged alphabet.
Pick a multiplier a that is coprime to 26, such as 5 or 11. Choose any integer for b, including 0. These parameters define the mapping (a x + b) mod 26 for encryption or its inverse for decryption.
Type or paste your message into the input field. Select encrypt or decrypt. The tool preserves case and punctuation automatically, so you do not need to strip spaces or symbols before running the cipher.
Click translate to see the result. Use copy to place it on your clipboard or download to save it as a text file. Press example to load a sample, or reset to clear the fields and start again.
Encrypt or decrypt with your own a and b values. Runs locally in your browser.