This chapter does not appear in the book.
Steganography is a familiar idea to readers of detective and spy novels. It involves the hiding of a secret message inside an innocent-looking package or container (often called a carrier). For example, a micro-dot hidden beneath a postage stamp, or a message written in milk on the back of a letter, or instructions tattooed under a person's hair.
Fortunately, this chapter isn't about an uncomfortable visit to a local tattoo parlor to have "I love Java" emblazoned on my scalp. Less sensationally, it's about using steganographic techniques to hide text inside PNG images.
The pictures at the top of this page shows the idea – the two images appear to be the same, even when compared minutely. However, the right-hand image has the text of a Java program hidden inside it.
Steganography is sometimes confused with cryptography, not surprisingly since it's a closely related idea. Cryptography scrambles a message, so an uninvited reader is unable to understand it. Steganography is about secrecy, so a potential eavesdropper won't even know there's a message to be read.
Steganography and cryptography can be combined to produce a hidden encrypted message – two levels of protection from prying eyes, which I'll implement using the Jasypt API. Jasypt supports basic encryption, without the programmer requiring a Masters degree in cryptography.
Another topic related to steganography is digital watermarking, which is employed for tracing and identifying digital media, such as images, audio, and video.
The cracking of steganographic messages is called steganalysis, and comes in two main forms. The easiest type of cracking simply makes the hidden message unreadable by modifying the carrier. This can usually be achieved by cropping or blurring the image, or saving it in a different file format. A much harder task is the extraction of the hidden message, which typically starts with the identification of tell-tale regularities or patterns in the carrier, or spotting differences between the carrier and its original. I'll discuss some basic steganalysis techniques using ImageJ, Java-based image processing software.
Protecting the hidden message when the carrier is modified is a hard problem. I'll implement two strategies which help a little: the duplication of the message in several different parts of the image, and the splitting up (fragmentation) of the message into multiple pieces. These techniques help to hide the message better, and can withstand (to some extent) the carrier image being cropped.
A good place for more information on steganography is its Wikipedia page, which includes links to steganographic software. Neil Johnson's Steganography and Digital Watermarking webpage is another great starting point, and links to his list of over 100 steganography tools.
How does steganography fit into my "Java Art" theme for these chapters? Back in chapters 1 and 2 my aim was to convert a program into an image, resulting in a rather pixilated, abstract picture. With steganography, a program can be hidden inside any image (so long as it's big enough).
This chapter describes four steganography applications: