Ciphers.

One of the books I’m writing involves a young woman training to be a secret agent in 1803 England. The running title is either “The Art of Deception” or possibly “Pride and Extreme Prejudice.”

Spies like her would need to be versed in secret communications. Unfortunately, possession of a code machine – like Jefferson’s disks – would automatically show that she was a spy. So would possession of secret inks.

She needs a cipher, one that she could easily generate, and one where she could easily destroy the evidence. Given what was available at the time, the best idea seems to be to move the invention date of the “playfair” cipher back a few years and have her use it.

Playfair was the top British cipher for much of the 19th century, which only shows how lame were the opposition. It is one step up from mono-alphabetic encryption (the cryptograms you sometimes have in the better newspapers (although not the AJC)). It encrypts pairs of letters, but in a systematic manner. On a small enough and random enough set of messages this can be really tough to break. A not dissimilar approach occupied Alan Turing for much of 1942 and 1943 when trying to break the German Naval Enigma (they used it to encrypt the rotor settings). Long chunks of text and repeated keys are much easier.

It starts with a keyword and a square (could be a rectangle).  Say “nevermore” and a 5×5 square.

1 2 3 4 5
2
3
4
5

Put the keyword (nevermore in this example) in the first row, dropping repeated letters. Then fill in with the rest of the alphabet. Have I and J in the same square.

n e v r m
o a b c d
f g h i k
l p q s t
u w x y z

Then for each pair of letters do one of three things.

  • If they’re in opposite corners of a rectangle (th above) take the other corners of the rectangle th -> kq and ht -> qk.
  • If they’re in the same row or column (gh above) take the letters to their right or below gh ->hi, is -> sy. Wrap around if you have to. There are alternatives here. It’s a pity they weren’t used because this is a weak point.
  • If the same letter occurs twice in a row, ‘ll’ for example, encode it as lx lx.

That’s all reasonable, except the distribution of pairs of letters is not flat. ‘th’ is by far the most common pair, and much more common than ‘ht’. So given a long enough message we can count pairs and from that deduce the structure of the 5×5 square. Repeated pairs are very useful because they define relationships between infrequent letters.

One simple way to harden playfair (though not enough to make it secure by modern standards) is to make the key ‘progressive.’

a n e v r
m o b c d
f g h i k
l p q s t
u w x y z
a b n e v
r m o c d
f g h I k
l p q s t
u w x y z

And so on until the 13th iteration. After that it begins to lose too much key to be unique. (Iteration 25 would always be just the alphabet in the square.)

a b c d e
f g h i k
l m n v o
r p q s t
u w x y z

Other schemes would be better than this, but you get the idea.

Author: rharrisonauthor

International man of mystery. Well not really, although I can mangle several languages and even read the occasional hieroglyphic. A computer scientist, an author and one of the very few people who has both an NIH grant and a book contract. A rising author of sweet romantic historical fiction. A booktrope author.

4 thoughts on “Ciphers.”

  1. Have you read any of Lauren Willig’s Pink Carnation series? She has a spy from the same era you’re looking at. Hers is the Pink Carnation (a riff on the Scarlet Pimpernel), with another spy known as the Purple Gentian. As the names indicate, her spy stories are told with tongue in cheek.

    Like

Comments are closed.