Tools
English

Neogie Affine · Word games

Affine Cipher: Encode and Decode Online

Choose a and b, or paste an unknown message: the most likely keys are suggested.

Settings

Everything happens in your browser: nothing you type is sent.

How does the affine cipher work?

Each letter gets a number, from 0 for A to 25 for Z. It is replaced by the letter numbered a × x + b, keeping the remainder after division by 26. With a = 5 and b = 8, “AFFINECIPHER” becomes “IHHWVCSWFRCP”.

So that two letters never give the same one, a must share no divisor with 26: it can only be 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23 or 25. When a is 1 you are back to the Caesar cipher.

Decrypting

You subtract b, then multiply by the inverse of a modulo 26. Enter both numbers and paste the message into the second box: the plain text appears.

Finding an unknown key

There are only 312 keys, one of which changes nothing. The tool tries the other 311 and ranks the results by comparing letter frequencies with those of the page language. The “Use” button applies a suggestion. With a very short message the right answer may sit lower down, or be missing from the list.

An exercise, not a protection

The affine cipher is a classic of modular arithmetic lessons. It protects no data: use modern encryption such as AES for that.

Frequently asked questions

Why is a = 2 not allowed?

Because A and N would give the same letter: decrypting would become impossible.

What is the inverse of a?

The number which, multiplied by a, leaves a remainder of 1 after division by 26. For 5 it is 21.

Are accents and digits encrypted?

No, only the letters A to Z change, unless you remove accents before encrypting.

Is my message sent anywhere?

No. Everything is computed in your browser.

How can I check a result by hand?

Take the first letter, count its rank from zero, multiply by a, add b, then subtract 26 as often as needed. The rank you get names the encrypted letter. With a = 5 and b = 8, F, rank 5, gives 33, that is 7: an H.

Similar tools

Neogie BrailleBraille Translator: Text to Braille and BackType text to see it in braille, or paste braille signs to read them. Neogie A1Z26Letters to Numbers Converter (A=1, Z=26)Type words to get numbers, or paste numbers to read the words. Neogie SemaphoreSemaphore Flag Alphabet: Encode and DecodeType a message to see the flag positions, or tap the drawings to read it. Neogie BaconBacon's Cipher: Encode and Decode (A and B)Five signs per letter: write a message or paste A and B groups to read it. Neogie CaesarCaesar Cipher: Encode and Decode OnlinePick a shift, or paste an unknown message and read all 25 attempts, ranked from the most to the least likely. Neogie PlayfairPlayfair Cipher: Encode and DecodeEnter a keyword: the square is drawn and the message is encrypted two letters at a time. Neogie VigenereVigenère Cipher: Encode, Decode and Find the KeyWith the key, the message reads at once; without it, the tool suggests the most likely keys. Neogie SubstitutionSubstitution Cipher and Frequency AnalysisEncrypt with your own alphabet, or rebuild the alphabet of an unknown message letter by letter. Neogie TranspositionRail Fence and Scytale Transposition CipherThe letters do not change, they change places: pick the method and the key. Neogie AtbashAtbash Cipher: the Reversed Alphabet OnlinePaste your text on either side: the same operation encodes and decodes. Neogie MorseMorse Code Translator with SoundType a message to see and hear it in Morse, or paste dots and dashes to read them. Neogie PigpenPigpen (Masonic) Cipher: Encode and DecodeType a message to draw it in symbols, or tap the symbols to decipher it. Neogie SyllablesOnline syllable counter: poems, haiku, textsType or paste a text: syllables are counted as you go, line by line and word by word. Neogie RhymesRhyming Dictionary: Find Words That RhymeType a word and see the words that rhyme with it, for a poem, a song or a game. Neogie AnagramAnagram generator: all the words from a set of lettersType some letters: all the words you can form with them, from longest to shortest. Neogie IdentifyCipher Identifier: Which Code Is This?A mysterious message? Paste it: leads are listed from the most to the least likely. Neogie TilesBest words from letter tiles, with pointsEnter the letters on your rack: the possible words, ranked from most to least profitable. Neogie ROT13ROT13 and ROT47: Encode and Decode OnlineThe same operation encodes and decodes: paste your text on either side. Neogie GuessWord of the Day Solver: right and wrong letter positionsEnter your guesses and their colours: the tool keeps only the words that are still possible. Neogie CrosswordCrossword and arrow puzzle solver by known lettersType the letters you have and one question mark per empty cell: the matching words appear.