Enter the maze

Dickens Knitting in Code

by Paul Curzon, Queen Mary University of London

Coloured balls of wool: copyright www.istockphoto.com 1867367

Charles Dickens is famous for his novels highlighting Victorian social injustice. Despite what people say, art and science really do mix, and Dickens certainly knew some computer science. In his classic novel about the French Revolution, A Tale of Two Cities, one of his characters relies on some computer science based knitting.

Dickens actually moved in the same social circles as Charles Babbage, the Victorian inventor of the first computer (which he designed but unfortunately never managed to build) and Ada Lovelace the mathematician programmer of those first computers. They went to the same dinner parties and Dickens will have seen Babbage demonstrate his prototype machines. An engineer in Dickens novel, Little Dorrit, is even believed to be partly based on Babbage. Dickens was probably the last non-family member to visit Ada before she died. She asked him to read to her, choosing a passage from his book Dombey and Son in which the son, Paul Dombey, dies. Like Ada, Paul Dombey had suffered from illness all his life.

So Charles Dickens had lots of opportunity to learn about algorithms! His novel 'A Tale of Two Cities' is all about the French Revolution, but lurking in the shadows is some computer science. One of the characters, a revolutionary called Madame Defarge takes the responsibility of keeping a register of all those people who are to be executed once the revolution comes to pass: the aristocrats and "enemies of the people". Of course in the actual French Revolution lots of aristocrats were guillotined precisely for being enemies of the new state.

Now Madame Defarge could have just tried to memorize the names on her 'register' as she supposedly has a great memory, but the revolutionaries wanted a physical record. That raises the problem, though, of how to keep it secret, and that is where the computer science comes in. Madame Defarge knits all the time and so she decides to store the names in her knitting.

"Knitted, in her own stitches and her own symbols, it will always be as plain to her as the sun. Confide in Madame Defarge. It would be easier for the weakest poltroon that lives, to erase himself from existence, than to erase one letter of his name or crimes from the knitted register of Madame Defarge."

Computer scientists call this Steganography: hiding information or messages in plain sight, so that no one suspects they are there at all. Modern forms of steganography include hiding messages in the digital representation of pictures and in the silences of a Skype conversation.

Madame Defarge didn't of course just knit French words in the pattern like a victorian scarf version of a T-shirt message. It wouldn't have been very secret if anyone looking at the resulting scarf could read the names. So how to do it? In fact, knitting has been used as a form of steganography for real. One way was for a person to take a ball of wool and mark messages down it in Morse Code dots and dashes. The wool was then knitted into a jumper or scarf. The message is hidden! To read it you unpick it all and read the morse code back off the wool.

The names were "Knitted, in her own stitches and her own symbols"

That wouldn't have worked for Madame Defarge though. She wanted to add the names to the register in plain view of the person as they watched and without them knowing what she was doing. She therefore needed the knitting patterns themselves to hold the code. It was possible because she was both a fast knitter and sat knitting constantly so it raised no suspicion. The names were therefore, as Dickens writes "Knitted, in her own stitches and her own symbols"

She used a 'cipher' and that brings in another area of computer science: encryption. A cipher is just an algorithm - a set of rules to follow - that converts symbols in one alphabet (letters) into different symbols. In Madame Defarge's case the new symbols were not written but knitted sequences of stitches. Only if you know the algorithm, and a secret 'key' that was used in the encryption, can you convert the knitted sequences back into the original message.

In fact both steganography and encryption date back thousands of years (computer science predates computers!), though Charles Dickens may have been the first to use knitting to do it in a novel. The Ancient Greeks used steganography. In the most famous case a message was written on a slave's shaved head. They then let the hair grow back. The Romans knew about cryptographic algorithms too and one of the most famous ciphers is called the Caesar cipher as Julius Caesar used it when writing letters...even in Roman times people were worried about the spies reading their equivalent of emails.

Dickens didn't actually describe the code that Madame Defarge was using so we can only guess...but why not see that as an opportunity and (if you can knit) why not invent a way yourself. If you can't knit then learn to knit first and then invent one! Somehow you need a series of stitches to represent each letter of the alphabet. In doing so you are doing algorithmic thinking with knitting. You are knitting your way to being a computer scientist.

In the Second World War, the United States censors held on to a letter that contained a knitting pattern so they could knit the jumper in case it did contain a message. Ultimately they banned people from posting knitting patterns overseas at all (along with playing chess by post) in case people were hiding messages in them.

Charles Babbage worked on codes too, and just as happened to the team at Bletchley Park in WWII, his work in the Crimean War was kept a military secret leading to others gaining the credit.