PCPlus 323: Secrets of Steganography

Ah, steganography, that art of hiding some message in plain sight. These days we’re attuned perhaps to just thinking of hiding a digital message by modifying the bits encoding an image, but it does have a long illustrious history before computers ever came along. There’s Herodotus and his idea of inscribing a message on a wax tablet, underneath the wax; microdots used by spies in WWII and later; using code-words in an otherwise normal-looking letter. But in the age of computers steganography really hits its stride.

Just think about it for a moment. The images we view on a screen are made up of pixels. Each pixel is 3 bytes of information: a byte each for the level of red, green and blue (I’ll ignore opacity). That’s 256 levels each. However the human eye really can’t differentiate the differences between a pixel that has an RGB value of, say, (200, 0, 0) and one that is of value (199, 0, 0). Just for fun here’s what those colors look like on your screen as you read this:

But...which is which? Is it the darker color on the top or the lighter? I forget… Let’s mix the colors up a bit and add some green and blue to make a lavender color:

Again it’s hard to discern any difference and I’ve even made these blocks 20 pixels to a side. So imagine a photo (obviously a BMP rather than a lossy JPEG) where, say, the first 8*100 bytes of pixel information encode a 100-character message, so there’s one bit of message per pixel. If the green channel is even, that’s a 0 bit, it is is odd, that’s a 1 bit, say. I would wager you wouldn’t notice that the image had been altered at all. I just post it somewhere public, say Facebook or Flickr, and everyone thinks it’s a wonderful photo, expect my compatriot who just decodes it with a simple program to get the message.

Unfortunately, life isn’t as simple as all that. The reason is that photos and images are JPGs and the JPG algorithm is a lossy one. The compression algorithm will smear out any simple color encoding like this. So for JPGs the problem is a little harder, but definitely not insurmountable. (For a idea of how JPG encodes and compresses an image see this previous PCPlus article, although this current article tries to lay out the basics.) In this case, you can fiddle the quantization matrices to embed the message, or play around with the Luma channel.

This article is famous – at least in the Bucknall household – for its diagram of how photo steganography works, using a stylized cat. There is no end to my drawing abilities…

(I used to write a monthly column for PCPlus, a computer news-views-n-reviews magazine in the UK, which sadly is no longer published. The column was called Theory Workshop and appeared in the Make It section of the magazine. When I signed up, my editor and the magazine were gracious enough to allow me to reprint the articles here after say a year or so.)