Loading…

How to use Affine Cipher

Type your text and set a multiplier (coprime to 26) and a shift key, and the tool encrypts it using the affine cipher formula.

Frequently asked questions

How does the affine cipher work?

Each letter's position x (0–25) is transformed with the formula E(x) = (a·x + b) mod 26. Decryption uses the modular inverse of a: D(y) = a⁻¹·(y − b) mod 26.

Why must 'a' be coprime with 26?

Only values of a that share no common factor with 26 (1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25) have a modular inverse, which is required to decrypt the message uniquely.

What happens to spaces and punctuation?

Only A–Z letters are transformed. Spaces, digits, and punctuation pass through unchanged, preserving the layout of your text.

More Text Encoding Tools

Polybius Square Cipher
Convert letters to row-column number pairs with the 5×5 Polybius square (I/J shared)
Tap Code Translator
Encode text as prisoner tap-code row,column taps and decode taps back to letters (K→C)
Beaufort Cipher
Encrypt and decrypt with the reciprocal Beaufort cipher using a keyword
Gronsfeld Cipher
Encrypt and decrypt with the Gronsfeld cipher using a numeric digit key
Vigenère Cipher
Encrypt and decrypt text with the classic Vigenère polyalphabetic cipher using a keyword
Autokey Vigenère Cipher
Encrypt and decrypt with the autokey cipher where the plaintext extends the keyword stream
Playfair Cipher
Encrypt and decrypt with the Playfair digraph cipher using a 5×5 keyword square (I/J merged)
Columnar Transposition Cipher
Encrypt and decrypt with keyword columnar transposition. Columns are read in alphabetical key order
Scytale Cipher
Encrypt and decrypt with the ancient Spartan scytale rod transposition cipher. Round-trip guaranteed
Keyword Substitution Cipher
Build a mixed cipher alphabet from a keyword and encrypt/decrypt monoalphabetic substitution text
Bifid Cipher
Encrypt and decrypt with the Bifid cipher combining a Polybius square with coordinate fractionation
Four-Square Cipher
Encrypt and decrypt digraphs using two keyword squares and two plain 5×5 squares. Round-trip guaranteed

← View all Text Encoding ToolsBrowse all 1,100+ tools →