dark mode light mode Search Menu

How to Create (and Crack) Secret Codes and Ciphers

JBrew on Flickr

While you can use computers to crack secret codes, also called ciphers, they’re not always needed. And computers on their own cannot decode secret codes. Computers need humans to provide directions. And humans have to think through a series of questions, develop rules for possible solutions, and decide when a possible solution should be abandoned in favor of another.

This project will lead you through a high level method to create secret codes and ciphers, as well as find ways to decode them. Obviously, the field of ciphers is vast and complicated. This puzzle is simply fun. I’ve also patterned this project on a more complicated Google lesson plan which is linked below. And I’ve collected a set of online links to help you figure out secret codes of your own, as well as ideas on how to crack them.

If you’re ready, let’s get started.

What is a Secret Code or Cipher?

A secret code, or cipher, is simply a substitution of one letter in an alphabet for another letter or number. I could say, for example, that instead of typing the letter E I will type the letter F instead. So house becomes housf.

Another type of secret code transposes, or changes, the order of letters in a message. So house might become uoesh.

Another way to create secret codes is to place meaningless words, letters, or characters between meaningful letters or characters. For example, you could take a piece of cardboard the size of letter paper, cut out squares or rectangles, place a piece of paper under your cardboard, write your message using the cut out cardboard spaces, then lift the cardboard and fill out the rest of your paper as if it was one letter. Only when you place the cardboard back down on your letter would you see your real message.

The process of encoding then decoding a message is called cryptography. To do cryptography, you will need a plain text message, a set of rules (algorithm) to encode your message, and a key to help decode your message. In some cases, you’ll also specify the time during which the algorithm and keys are in effect.

Ciphers are slightly different from codes. A cipher mixes up or uses different letters or characters. A code substitutes one word for another word or sentence. For example, FWIW or OMG are codes, aren’t they? FWIW replaces for what it’s worth and OMG replaces Oh My God!

For this project, we’ll focus on a simple pattern to substitute letters and characters.

How Do You Create a Secret Code or Cipher?

Remember my example of replacing the letter E with the letter F, so house becomes housf?

What happens if I say the letter E will be replaced by the letters F plus the letters R and K? What happens if I need to use a word with F, R, or K in them? Creating a sentence this way could get confusing very quickly. The solution is to create a pattern, or set of rules (called an algorithm in computer science), used to translate any sentence encoded with your pattern.

To start, let’s say our pattern will simply shift all letters in the alphabet two spaces to the right. So the letter E becomes the letter G, the letter G becomes the letter I, and so on.

With this simple pattern, house becomes iqwug. Could you figure out what iqwug means?

How Do You Crack a Secret Code or Cipher?

Remember our simple pattern where we shifted the letters of the alphabet two spaces to the right, so house becomes iqwug? Let’s talk about ways we might crack or decode this word.

What you might notice first is that iqwug is an extremely small sample, a word of only five characters in length. To crack any code, you need as many examples of encoded words, sentences, and paragraphs as possible. One five character word might be impossible to crack without other examples.

When you have a large sample of words and sentences encoded with the same pattern, it becomes possible to apply other patterns. For example, in the English language, the letter E is very common.

A large sample of encoded words with our pattern which shifts letters two spaces, turning the letter E into the letter G, would likely have more Gs than most or all other letters. We could begin to try and decode our sentence by changing the letter G to E. Then we could look at how E became G: we might realize G is two letters to the left of E in the English alphabet and try shifting the other letters in our encoded message two spaces to the left.

Decoding and deciphering encoded messages requires lots of thought, as well as trial and error. It’s a fun puzzle to solve.

Try Your Own Cipher

If you recall, to encode and decode a message you will need:

  • A plain text message.
  • A pattern or set of rules to encode and decode your message.

You also could use a key, for example, a dictionary, and set a period of time when your pattern or set of rules is active before it is replaced by another pattern used to encode and decode messages. But these are optional steps and not required to have a little fun with codes and computational thinking.

To create a simple substitution cipher, take a piece of paper and write out every letter of the alphabet. Next to each letter, assign another letter, number, or character to represent the original letter. You can assign these randomly or in a set pattern, for example, assigning the second or third character to the right or left of the original letter. So A might become X if you shift three characters to the left.

Once you have a message to encode, refer to your alphabet and rewrite your message with the letter, number, or character assigned to each letter.

To make things more interesting, work with a partner to create your own substitution patterns and trade encoded messages. See if you can figure out the method of substitution required to decode the message.

If you need a long message, or can’t think of a message, copy text from a book or web page to encode and decode. Longer plain text will allow you to see how letter frequency might help decode a message.

Learn More

Ciphering a Sentence (Google)


Cipher (Wikipedia)


Letter Frequency

Some resources with information about how common individual letters are in the English language. The Wikipedia article includes data on Spanish, Turkish, Swedish, and other languages.

The Secret Language


Secret Codes for Cubs and Scouts


Three Secret Codes to Try With Your Kids


Create Secret Codes and Ciphers (Wiki How)


Cryptography (Wikipedia)