Wednesday, March 09, 2011


The idea of practicing steganography in images has fascinated me since I first heard about it. The idea is that, if you don't know that there's supposed to be some hidden message encoded in something, you could look at it and never suspect; but it's right there, right in front of you. It doesn't even have to be enciphered.

One simple but powerful way to do this is to have two successive frames of video that appear to depict the same image, but there's actually very subtle differences in the color values, too subtle for the human eye to readily detect. However, compare the numerical values of all the pixel color values. Whereever the one in the second image is higher than its partner in the second image, write a 1. Wherever the second is lower, write a 0. Where they're the same, don't write anything. You can hide thousands of bits in a pair of tiny images with no way a human eye could even realize anything was there to find.

Listening to Siobhan talk about how this or that knitting pattern is "knit 1, purl 2, then knit all", it occurred to me that one could probably use a scarf as a form of steganography. Simply encode a message in binary, then start your knitting, doing a knit every time you see a 1 and a purl every time you see a 0. Siobhan assures me that the result would be fairly structurally sound (though if not, you could easily reserve a few stitches and rows at the edges for non-signal structural stitches) and wouldn't look like anything particular -- just a randomly-speckled scarf surface. With 30 stitches per row and several hundred rows, you can store a page or two of information just using 7-bit ASCII; if you use a Huffman encoding with a predetermined dictionary you could easily double that, or even more, if your dictionary didn't just encode letters but also common words or phrases.

Of course knitting is pretty slow, so it's hard to think of applications that wouldn't be impractical, or at least cinematic. I can easily imagine this coming up on the TV show Chuck. Imagine Morgan walking in on Sarah knitting, and being surprised that a kick-ass spy knits, only to find that she's really encoding a message that will be delivered to some underground rebel group in a police state through a dead drop -- it'll simply be put up for sale in one of the street markets. Imagine Doctor Who (the Tom Baker iteration) revealing that he keeps secret plans on that huge scarf of his, so that even if is captured by the Master, the secret won't fall into the wrong hands. Silly, but quite apropos to those shows.

Realistically, though, would there ever be a situation where something like this could be useful? Probably not. There are simpler but equally effective ways that don't require so much time or equipment. Siobhan suggested someone spying on a conversation and recording key facts without arousing suspicion by simply appearing to be knitting, but why not just have a recorder in your pocket? Maybe the best possibility would be using it to store some important information in such a way that, even if someone searches you or your apartment, they won't recognize or confiscate it.

The idea is ultimately too goofy for real life, but compelling enough to use as a plot device in an adventure or story. (Then again, a lot of goofy-seeming spy techniques have been used somewhere in the real world. I wonder if this is one of them.)


Tyler said...

In A Tale of Two Cities, Madame Defarge encodes the names of those to be executed in her knitting.

Oogie McGuire said...

Used in real life in WW II but more by putting knots in the yarn first then knitting it. An older lady was a spy in the Revolutionary war but she hid her notes in balls of yarn she kicked off a cliff to the waiting folks below. She sat knitting near British armies.

And I love the Dr. Who idea, have to think on that, might be worth making a version of the scarf with a code in it....