Skip to content

Substitution Cipher Decoder and Encoder with Custom Key

Set a key of 26 letters and type your text, and the result appears as you go.

Ready: all 26 letters, each used once.

Mode
Result

The alphabet is on top and your key below it. Each bar counts how often that pair is used in your text.

Pick two key letters to swap them.

advertisement

What is a substitution cipher?

A substitution cipher replaces each letter of the alphabet with another letter, following a key. One fixed alphabet covers the whole message, which is why it is also called a monoalphabetic cipher. The Caesar cipher is a special case where the alphabet simply slides along, and Atbash is another where it runs backwards. Here the key can be any order of the 26 letters.

How does a substitution cipher work?

Write out the alphabet and put the key underneath. To encode, find each letter in the top row and take the one below it. With the key QWERTYUIOPASDFGHJKLZXCVBNM, A becomes Q, B becomes W, and HELLO turns into this:

How does a substitution cipher work?
Text HELLO
Result ITSSG

To decode, go the other way: find the letter in the bottom row and take the one above it. I sits under H, so I goes back to H. Switch the tool to Decrypt and it does this for you. Upper and lower case stay as they are. The tool changes only A to Z, so digits, punctuation and accented letters come through untouched.

How to make a substitution key

The Random button shuffles the alphabet for you, though the result is hard to remember. To get a key you can keep in your head, start from a keyword: write the word, drop any repeated letters, then add the rest of the alphabet in order. The keyword CIPHER gives this key:

CIPHERABDFGJKLMNOQSTUVWXYZ

Paste it into the key field to use it. Whoever decodes your message needs the same key, so copy yours before you press Random again. To adjust a key, pick two letters in the key row and they trade places.

How to decode a substitution cipher without the key

This tool needs the key and will not solve a message for you, but you can often crack one by hand. There are about 4 × 10²⁶ possible keys, far too many to try one at a time, so you count letters instead. A key changes which letter is used and leaves the number of uses alone, which is what the bars above the key show. In the sample this page opens with, E appears 9 times, and T, its partner in the key, appears 9 times in the result. Run your text through the frequency analysis tool and match the most common letters to E, T and A, the usual leaders in English. Then look at short words: a one-letter word is probably A or I, and a frequent three-letter word is often THE.

A short history

The earliest known account of breaking a cipher by counting letters comes from the Arab scholar Al-Kindi in the 9th century. Substitution stayed in use long after that. In 1586, Thomas Phelippes decoded the letters of Mary, Queen of Scots, written in a substitution cipher mixed with code words, and they were used to convict her. Today you are more likely to meet it as the cryptogram in a puzzle book.

Substitution, Caesar and Vigenère compared

Caesar has only 25 useful keys and Atbash has one, so you can test them all in moments. A substitution key is far too long a shot to guess, yet the bars give it away just as they would for Caesar. Vigenère changes the alphabet as it goes, so the same letter can come out differently each time, which hides those counts much better.

Frequently asked questions

Can this tool solve a substitution cipher without the key?

No. It encodes and decodes with a key you supply. For a message with an unknown key, use the frequency analysis tool and the steps described above.

What does monoalphabetic mean?

It means one alphabet. Each letter turns into the same letter every time, all through the message.

Can a letter stand for itself?

Yes. The tool only checks that each letter appears once, so a key may leave a letter unchanged. A random key sometimes does.

Is a substitution cipher secure?

No. A few lines of text are often enough to break it, so use it for lessons and puzzles. Real data needs modern encryption such as AES.

What happens to numbers and accented letters?

They stay as they are. The key covers the 26 letters from A to Z, and everything else passes through unchanged.

Is my text sent to your server?

No. The tool on this page runs in your browser, so your text and key are not sent to our server.

More cipher tools and guides