This instructable is intended to demonstrate practical codes that are many times harder to crack than the codes you normal find in newspapers and puzzle books. This is the real deal - codes that have been used by real-life spies during such high risk times as WWII. These are for a variety of situations, from keeping your club house a secret to keeping your formula for rocket fuel safe.
Listed below is a short glossary of terms, should you need it:
A method of concealment in which entire words or phrases are substituted for other words or phrases. Example: dog = hideout. This means that most of what people call "codes" are not really codes, but ciphers (see below). Everything in this instructable is a cipher, except for the book code as noted in step 4. However, since everyone is used to hearing the word "code," I will use it interchangeably with "cipher" throughout this instructable.
A method of concealment in which individual letters are substituted or transposed (switched around). Example: Agent = tnega (Agent backwards). Pig Latin is also a cipher.
A method of encryption in which the letters in the alphabet are replaced directly. This means that everywhere an S appears in your message, it would be substituted with, for instance, M. This is generally a weak type of encryption.
This means that a letter could have more than one meaning. So every time an S appears in your message, the first time it might get replaced with an E, the next time with a W, then a D, and so on. Every cipher in this instructable is poly-alphabetic.
A key is what is needed to decode a message. It may be a word known only to you and your partner (such as the Playfair cipher in step 2), the settings of rotors for the Enigma machine in step 3, or a title of a book for the book code in step 5
Brute force attack
This is when someone tries to break a code by just trying every single possible combination, one at a time, until they get something that makes sense. The average person can break a mono-alphabetic cipher this way, but anything more complicated will likely need a computer.
Your message before it is encrypted. (readable)
The message after it is encrypted (unreadable)
Step 1: General Rules
It is important that you select a code that is fitting to the situation. When sending secret messages, those that might try to break your code will fall into one of three categories:
A. General population.
This will be 99.9% of everyone you know. Usual, the most difficult type of message this group
can break is a mono-alphabetic (see intro) cipher. This is why this instructable does not give
any mono-alphabetic ciphers - almost everyone can break them! They are included under the
name Cryptograms in many newspapers next to the crosswords.
I have nothing against geeks - I am one. This group is not to be taken lightly. They will
probably know about any type of cipher you are considering, so it is best to make it a difficult
one. They may also have encryption breaking software and be able to use brute force attacks.
If you get on the wrong side of the government, all I can say is good luck. They have seen
every trick, and cracked harder codes than you ever thought of producing. The best policy is
to keep your messages limited to common tasks like keeping the next meeting location
of SSOBACCG (Secret Society Of Boys Against Cootie Covered Girls) a secret.
Here are some general rules to follow that will make any code or cipher more difficult to break:
1. Keep it short.
The longer a message is, the easier it is to break using the frequency
that a letter appears (E is the most common), patterns, and other techniques.
Using abbreviations will also help detour software-based code breaking that
might be checking possible solutions against a dictionary to see if it makes sense.
2. Break coded messages into groups of 4 letters.
This is a technique that has been used by spies for decades. This keeps someone
from guessing a message based on word length (ex: a single letter is either I, a,
and sometimes o) Also, it helps to keep someone decoding the message form
losing their place by having it in manageable chunks. Example: AFRT CGTJ VGTY SFVT.
3. Never send the key with the code.
It might be temping to send the keyword (if you were using the telegraph code, for
example) with the message. However, you should always arrange the keyword ahead
of time or send it in a separate message. If someone has the keyword, it is just a matter
of trying every type of encryption.
4. Change the key often - consider using a one-time pad.
It is important that, if someone does break your code, the knowledge of how to translate it
has a very short life. Change the key as often as practically possible. Every week is good,
certainly not more than every month. A very good idea would be to use a one-time pad of
keys. For example, if you were using the Playfair cipher (Step 3), your one-time pad would
be a list of keywords, and as you sent messages back and forth you would go down the list
using each word only once. Then, the entire sheet would get replaced every so often in
case it was discovered.
5. Use dummy characters.
After you message is encoded, consider throwing in some random characters to make it
harder to crack. The person recipient of message would know to discard, say, the first
and last three characters of the message before decoding.
6. Avoid punctuation.
Punctuation can provide a code breaker with valuable information - for example, sentences
that end with a question mark often start with a W (what, when, where, why).
Step 2: Playfair Cipher
The playfair cipher was used extensively in the Boer war and WWI. To my knowledge, it is one of the easiest poly alphabetic ciphers there is. It does not need any props or long tables to use like some ciphers - just a knowledge of the keyword and a 5x5 grid.
1. To start, pick a keyword that has no repeating letters. This example will use the word "codes."
2. Next, take the plaintext message (the message you want to encode) and split it into pairs of letters. If there is an odd number of letters, add an X to the end. If there are two of the same letter paired up, split them up by inserting an X. This is shown in the example "Tonight is not possible":
Plaintext: TONIGHT IS NOT POSSIBLE
Split into pairs: TO NI GH TI SN OT PO SX SI BL EX
3. Next, draw a 5x5 grid, and fill in the first boxes with your keyword. Then, fill in the rest of the boxes with the rest of the alphabet, putting I and J in the same box (as shown in the photos).
4. Now you are ready to start encoding. The rule to remember is "Right, and Down." Take the first pair of letters and find them on the grid. They will either be:
Not in the same row or column - this means that the letters will form two corners of a square. The code letters will be the other two corners. In other words, for the pair TO, go right from T until you are in O's column. In this case, this means that the code letter for T is Q. Look at the pictures to get a visual on what is happening (photo 1).
They are in the same row - go right one letter. For the pair NI, go right one letter from N to give you I. Go right from I one letter to give you J (see photo 2).
They are in the same column - Go down one letter. For the pair DL, go down one letter from D to get F. Go down one letter from L to get R. This case does not occur in the example "tonight is not possible," however photo 3 shows how it would work.
5. Finished! The final message for "Tonight is not possible" is "QEIJ HAUM EQQC DZCN FKDY"
To decode the message, just reverse the process in step 4 above. This means that to decode you will use split the coded message into pairs, follow the rule "Left, and Up", and remove the extra X's when you are finished.
Step 3: Enigma Code
This is it - the most famous code machine ever invented. It took the brightest mind in England plus the world's first computer months to crack it in WWII. It is the most secure cipher in this instructable - no one without specialized computer software will break it, ever. The history of the Enigma machine is amazing! There is a very excellent movie called "Enigma" that shows its role in WWII.
Attached to this step is .zip that contains an Enigma simulator (see screen shot). It has a full tutorial included on how to use it.
I have used this without any problems and scanned it with my antivirus software. However, it is always a good idea to scan anything you download from the internet with whatever antivirus software you have on you computer. If you wish, you can download it from the source by going to http://www.xat.nl/enigma/ or just run a Google search for "enigma simulator."
Step 4: Book Code
This is a very good code - simple, yet extremely difficult to break.
It involves taking each letter in your plaintext message one at a time, and writing down where you found it in a book that both you and your partner have. For example, the series 126-9-23 would mean go to page 126, and find the 23rd letter on the 9th line.
If I were to use Wind in the Willows (http://www.amazon.com/Wind-Willows-Signet-Classics/dp/0451530144/ref=sr_1_3?ie=UTF8&s=books&qid=1246749658&sr=8-3) to encode the message "Yes," it would look like this: 5-7-5, 5-8-29, 5-4-6. If I wanted to group my message into sets of 4 (see step 1), then my I could assign three numbers for the page, two for the line, and two for the letter# on that line making it 005-07-05, 005-08-29, 005-04-06, which then becomes 0050 7050 0508 2900 5040 6000.
There are two drawbacks to this cipher. First, it takes a long message to hide a short one. Second, you and your partner must have exactly the same book. This means that not only do you both have Wind in the Willows, but you both have the Signet Classics 2006 paperback version. A good way to ensure this is to use ISBN numbers (the numbers above the bar code on the back of the book) when specifying which book you will use.
A neat way to work this is to use the same library as your partner. You go in one week, check out a book, encode your message and send it to him, then return the book. Next week, he goes to the library to check out the same book.
Step 5: Steganography
This is a big fancy word that means "Hiding a secret message within a larger one in such a way that others can not discern the presence or contents of the hidden message." (www.dictionary.com)
This it not technically a cipher, but I am including it in this instructable because sometimes it is not enough to say "I saw Bobby throwing water balloons out the window at Sally" - sometimes you need to send the picture showing it!
Attached is an application that takes a file (such as a photo, word document, etc.) and hides it in a photo by changing certain pixles in the photo. The photo of Wallace & Gromit shown has the picture of the Instructables robot hidden in it, but you can not tell that there is anything different about it.
There is a size limitation - you can only hid a file that is about 40% the size of the photo you are hiding it in.
I have used this without any problems and scanned it with my anti-virus software. However, it is always a good idea to scan anything you download from the internet with whatever antivirus software you have on you computer. If you wish, you can download it from the source by going to http://stegoshare.sourceforge.net/index.html or just run a Google search for "Steganography".
Step 6: Further Resorces
The following are some very good resources it you want to dig deeper into secret messages:
https://www.instructables.com/id/Encode-data-in-2D-on-your-T-shirts-business-cards/ - Nice bar-code based encryption that only those with a scanner can read.
https://www.instructables.com/id/Secret-Sour-Sayings/ - secret writing w/lemon juice
https://www.instructables.com/id/Make-your-own-secret-code/ - Mono-alphabetic codes
Codes, Ciphers, and other cryptic abd clandestine communication by Fred B. Wrixon
Secret Messages (Usborne Spy Guides) by Travis Falcon and Judy Handley
http://www.xat.nl/enigma/ - Enigma simulator
http://stegoshare.sourceforge.net/index.html - Steganography
http://home.comcast.net/~ebm.md/stego/softwarewindows.html - Steganography