Codes and Cyphers

By David A. Cooper

Some codes like Morse Code and Semaphore are used to enable communications at a distance, while others are used to hide the content of messages from outsiders. I will take a little look at the former type of code, and then move on to the main event.

There are a number of different systems used by deaf people to spell out words using their hands, but most hearing people can't be bothered learning any of them because they are too hard to learn and too easy to forget. However, I've noticed a pattern in the alphabet which could change all that. Take a look for yourself: a (b c d) e (f g h) i (j k l m n) o (p q r s t) u (v w x y z). The five vowels are spaced out through the alphabet, and each is followed by a group of three or five consonants: perfect for an animal with five fingers on each hand. You just use one hand to indicate which vowel you're starting at, and the other hand to say how far to go on through the alphabet from there to get a consonant, so if you extend three fingers on one hand (representing "i") and then hold your other hand lower down with five fingers extended, that would represent "n". This system is very easy to learn, and very hard to forget.
indentSemaphore is also hard to learn and easy to forget, but it's also hard to read because everything's suddenly reversed left to right when you watch someone else signaling to you. Again the solution is to use that pattern in the alphabet instead: one arm can be used to select a vowel, while the other can optionally be used to convert it into a consonant. The letter "a" is formed by putting one arm into the "teapot handle" position with your hand on your hip; "e" is formed by holding your arm out to the side, but sloping down at an angle of 45 degrees; "i" is formed by holding your arm out to the side horizontally; "o" is formed by holding your arm out to the side, but sloping up at 45 degrees, and "u" is formed by holding your arm straight up in the air. The other arm is held by your side if a vowel is being signed, but it can go through the same five positions as the vowels to indicate consonants, so if you imitate an aeroplane (both arms held out to opposite sides horizontally), then that's the letter L. It doesn't matter which arm you use for vowels and which you use for consonants because you will always put the vowel arm into position slightly before the consonant arm.
indentMorse Code is again hard to learn and remember, so in most emergency situations it is practically useless because you can be sure that one or other party won't know it. That pattern in the alphabet can come to the rescue yet again: just flash a series of dots to indicate a vowel, but turn the last of these into a dash if you are going to convert it into a consonant, and then send more dots to count through the alphabet from that vowel to the consonant you require."Dot dot dash dot dot (..-..)" represents the letter K (aei, jk). "Dot dash dot dot dot (.-... ae, fgh); dot dot (.. ae); dot dot dash dot dot dot (..-... aei, jkl); dot dot dot dash dot (...-. aeio, p)" represents the word "help". You can store the number of flashes on your fingers as you read the signals and then take your time to decode them before signalling with a single flash that you are ready to receive the next one.

Try out the three communication systems above with a friend to make sure you know how to use them correctly. The key skill you need to acquire is the ability to count your way through the alphabet starting from the places where the vowels are, but once you've got the hang of that you will find the three systems are extremely easy to use, and you'll be hard pushed to forget them.

Cyphers

A cypher is a kind of code where all the letters in a message are changed in an attempt to keep the content secret from people who aren't meant to read them. A simple cypher might replace "a" with "b", "b" with "c", "c" with "d", and so on. The message "meet me at midnight" would therefore become "nffu nf bu njeojhiu". Of course, if that message fell into enemy hands, it would be fairly easy to crack this cypher because it's such an obvious one to use. It would be much better to write the alphabet out a less predictable order and then use that as the basis for a more secure cypher:-
```
a b c d e f g h i j k l m n o p q r s t u v w x y z
r e w q p o i u t y v c f d x z s a j k m n l b g h
```
Now "meet me at midnight" now becomes "fppk fp rk ftqdtiuk". Unfortunately, this is still not a safe way to keep your messages secure against outsiders. There are patterns which give clues as to what some of the letters might be, such as the "pp" in "fppk" which could help an enemy crack the cypher, and there is also the problem that some letters are more common than others, so all an enemy needs to do is count how many times each letter appears in a message and he can guess that the most common ones are likely to represent "e" and "t". Unless the message is very short and has an unusual lack of the most common letters, it can usually be cracked fairly easily: if you use a computer to help, you can often crack a message in a matter of minutes (or under a second if the program has access to a dictionary and can do the entire job for you).
indentTo show you how easy it is to crack a cypher, I have written a couple of programs for you to play with. The first one enables you to encode messages using the cypher of your choice. Once you have written and encoded your message, you can highlight it and press ctrl+C to copy it. You can then use ctrl+V to paste it into the other program designed for decoding and cracking messages. Here are the two programs:-

And here's a message for you to try to crack:-

ejrpxxlgdw mcmaimuupo mulpeqmlcp lnmapumpuk xgpurwkuje mqmlpvumrw mcmkuplmcr pkepijverj zxvlnkehjx hmakekrfwm erwmgpcmrw kuuwjcrkwp hmamxkqmcp rmxgdvrrwm fjcarwmwmc mfwmcmkrfj vxajrwmcfk umejrwphmj llvccmasvu rrjwmxdgjv ujxhmkrqvr pxjeomcdkm lmjzrmyrfj vxawphmrwm fjcarwmipe grkimujhmc.

The most common letter (assuming the message is written in English) is usually "e", though "t" is normally close behind. If you look at all the places where "t_e" appears in the message, you may be able to guess which letter represents "h", and you can then look out for words containing those three letters (then, there, here, where, three, other, etc). The next most common letters tend to be "a", "h", "i", "n", "o", "r" and "s". When trying to crack the message above, you may reach a point where you find "...where_two..." but it is unlikely that the words "where" and "two" are both parts of the message given the lack of room between them for anything other than an unlikely one-letter word, so you need to think about where a split might actually occur: perhaps the missing letter is "i" and it joins up with the "t" to make the word "it"? You can then think about what sort of word might start with "wo": it is likely to be a five letter word ending in "d", because the "d" can't join up with the next word and there aren't many three-letter words starting with "wo" or two-letter words ending in "d". If you want to get a better idea of how common all the different letters are in a typical piece of text written in English, just copy this paragraph and paste it into the input box of the second program, then when you click on "Post" you'll see how often each letter occurs in it. The letter "l" comes tenth, so whenever you get stuck decoding a message it may be worth trying the ninth, tenth or eleventh most common letter as a "l" and seeing if it produces any words.

So, simple cyphers can be cracked and are therefore insecure, but you can make your messages more difficult for outsiders to crack if you throw a little chaos into them. One trick is to use more than 26 symbols so that you can have more than one letter for "e" to make it behave as if it is a less common letter. By doing this for the other common letters too, you can make most of them appear equally frequently. You can also throw in lots of "nulls": letters which are not a real part of the message and which can be ignored by the person you're sending it to once it has been decoded. As you can szee fromq thqis izt is stillq possizble xto maxke out what isx beizng saiqd evenq with lotzs of nuqlls addedx to it, though the way you add them could actually make it easier to decypher if you do it badly (an artificially regular spacing between the nulls may flag them up as just that: nulls).