Enigma Machine

Enigma Machine
German Enigma Machine

Monday, December 8, 2008

Shift Ciphers

First, let's look at the terminology of encryption. When we say encrypt we mean to scramble a message so it is unreadable by anyone but the intended recipient. To decrypt a messages, means to unscramble a scrambled message.

Most encryption methods have a special piece of information that is kept secret and it is shared between the two people wanting to talk securely. That special information is called a key.

So one of the easist ciphers to understand and use is known as a shift cipher. Here we show two copies of the English alphabet. The second copy is shifted (and we wrap the extra characters around the back end):

ABCDEFGHIJKLMNOPQRSTUVWXYZ

DEFGHIJKLMNOPQRSTUVWXYZABC

Now, if we agree with a friend that we are going to shift our alphabet by 3 places, one of us can encrypt a message by 'looking up' the next letter of the message on the top alphabet and writing the corresponding letter from the bottom alphabet. Similarly, when the receiving party wants to decrypt a message, they lookup each character in the encoded message on the bottom alphabet and write the corresponding letter from the top alphabet.

Let's try a message. By the way, with the above alphabets, we can consider that special secret information (the key) to be '3' since that is the number of letter positions by which the alphabet is shifted. Encoding the message:

WE WILL ATTACK AT DAWN

is translated to :

ZH ZLOO DWWDFN DW GDZQ

Not too bad. But anyone who likes the Sunday newspaper cryptograms knows how to try to decode this. They would look at the smaller letter groups and make guesses as to the words they represent. There are a limited number of short words in english (i.e. IF, OF, TO, ON, UP, AT, etc.) Also, because the two groupings ZH, and DW don't share any letters, you know, for instance, that if one of the words is OF, the other cannot be ON, TO, OR, SO, or NO. In general, once the encryption is complete, you want to write the letters in same size groups as follows:

ZHZLO ODWWD FNDWG DZQZH

Note that we added a couple of characters. This will not matter to the receiver. They have the key and will quickly decrypt the message. Seeing the extra letters at the end will easily be recognized as some 'padding' of the message and be disregarded.

So, shift ciphers like this are of a class of codes known as Monoalphabetic ciphers. This simply means 1 letter 'maps' to 1 letter. These are the easiest codes to break even in the absence of knowing the 'key'

One more note: You can shift the alphabet by anywhere from 1 to 25 places. Shifting the alphabet by exactly 3 characters has a special name. It is a Ceasar cipher as it was created by Julius Ceasar for use in communicating with troops during many of their wars.

Next time, I will try to talk about how to attack this cipher.

No comments: