**Audio recording of blog post:**

The latest edition of 2600 Magazine has an interesting article about encryption. It explains a way to encrypt messages by hand, without the help of a computer. It's a two-step process: First, the message is converted into a series of numbers. And second, it is encrypted using a secret key.

This kind of encryption technique is thought to be used by spies to decrypt messages from **number stations**. Number stations came into existence shortly after World War II and still exist today. They are short-wave radio stations that are silent most of the time, but occasionally will broadcast a voice that reads off a series of numbers. These numbers are thought to be encrypted messages for spies in the field. The Conet Project has a great collection of freely-downloadable recordings from number stations.

In this blog post, I'll describe how perform this encryption technique.

# Cypher

The message must first be converted into a series of numbers before encryption can occur. This is done using what's known as a **simple substitution cipher**, where each letter in the alphabet corresponds to a numeric code. An example of a very basic substitution cipher looks like this:

*Each letter in this simple substitution cipher has a two-digit code.*

This cipher assigns two-digit codes to each letter. The code `01`

is assigned to the letter `A`

, `02`

to the letter `B`

, and so on up to `26`

for the letter `Z`

.

However, there is a more efficient way to encode each letter. A cipher called a **straddling checkerboard** takes advantage of the fact that certain letters in the alphabet are used more often than others. The numeric codes for these letters have only one digit, while the codes for all the other letters have two. This makes the cipher text shorter, which makes the message easier to encrypt and decrypt.

*A "straddling checkerboard" is arranged so that the most frequently-used letters are only one digit long.*

The image above shows the straddling checkerboard that we'll use. The most frequently used letters in the English language ("AEINORST") appear on the top line. The author chooses to arrange them in a way that makes them easy to memorize ("AT ONE SIR"). However, they can be arranged in any order, as long as the person decrypting your message uses the same arrangement. The rest of the alphabet appears in the rows below.

The dashes you see on the first row are called **shift characters**. You use them to "jump down" to another row in the table. For example, the number `2`

in the first row is a shift character, which means that `2`

will be used as a prefix for the characters that are in the row labeled `2`

(the second row). The number `6`

in the first row is also a shift character, meaning that `6`

will act as a prefix for the characters that are in the row labeled `6`

(the third row). For example, the word `WOMBAT`

translates to `64 3 29 20 0 1`

.

But what if your secret message has numbers in it? Well, numbers are encoded in a special way. The `#`

character in the table represents the number escape character, which encodes to `69`

. The number, when encoded, will *start and end* with `69`

. Also, each digit in the number is repeated three times. For example, `2012`

becomes `69 222 000 111 222 69`

.

# Encryption

Before the message can be encrypted, a secret key must be generated. The key is a series of random numbers and must be at least as long as the ciphered message itself. If the key is longer than the ciphered message, then "0"s are appended to the message.

So, let's encrypt the message `OCEANS11`

using the key `62206 45175 09174 12846`

. Note that, spaces are inserted for readability purposes and are not part of the message or the key.

```
32150 47691 11111 69000 (plain text)
- 62206 45175 09174 12846 (key)
-------------------------
70954 02526 12047 57264 (encrypted)
```

The plain text message contains 17 digits. Because my key is 20 digits, I append three zeroes to the plain text so that it matches the size of the key. Then, I subtract each digit in the key from each digit in the plain text. If the result is less than zero, I add 10. For example, in the first column, I calculate `3 - 6`

, which results in `-3`

. Because this is less than zero, I add `10`

to get `7`

as the final answer. In the second column, the result of `2 - 2`

is `0`

, which is *not* less than zero, so I leave that as my final answer.

# Decryption

```
70954 02526 12047 57264 (encrypted)
+ 62206 45175 09174 12846 (key)
-------------------------
32150 47691 11111 69000 (plain text)
```

Decrypting a message involves adding each digit in the key to each digit in the encrypted text. If the result is greater than `10`

, then `10`

is subtracted from the result. For example, in the first column, the result of `7 + 6`

is `13`

. This is greater than `10`

, so I subtract `10`

to get `3`

as my final answer. In the second column, `0 + 2`

is `2`

, which is not greater than `10`

, so I leave this as my final answer.