Steganography explained
A message nobody can read still tells everyone that a secret exists. Steganography goes one step further: it hides the message itself, in something so ordinary that nobody thinks to look. For more than two thousand years that meant shaved heads, wax tablets and invisible ink; today it usually means the lowest bits of the pixels of a photo.
Hidden writing, not secret writing
Cryptography transforms a message so that only someone with the key can read it, but the ciphertext is there for all to see, and a stream of gibberish attracts attention. Steganography hides the fact that there is a message at all. The two are often combined: a message is first encrypted, then hidden, so that even if it is found it cannot be read. The word was coined by the abbot Johannes Trithemius, whose Steganographia, written around 1499, looked like a book of magic spells and was in fact a manual of hidden writing.
From shaved heads to microdots
Herodotus tells how Histiaeus shaved the head of a trusted slave, tattooed a message on his scalp and sent him once the hair had grown back, and how Demaratus warned Sparta of the Persian invasion by writing on the wood of a wax tablet and covering it with fresh wax. Later centuries used invisible inks of lemon juice or milk that appear when heated, letters marked by tiny pinpricks, and the null ciphers of spies, where the first letters of innocent words spell the message. In the Second World War German agents shrank whole pages to microdots the size of a full stop.
Hiding bits in pixels
A digital photo stores each pixel as three numbers from 0 to 255 for red, green and blue. The lowest bit of each number, the least significant bit, only decides whether the value is even or odd: replacing it with a bit of the message changes the colour by one step in 255, which no one can see. One bit in each channel gives three bits per pixel, so a picture of 720 × 480 pixels can carry about 125 kB, a short novel. Using the lowest two, three or four bits multiplies the capacity, but the changes of up to 15 levels begin to show as grain in skies and smooth skin. A short header records the length and the settings so that the receiver can read the bits back in the right order.
Bit planes, the difference and PSNR
Splitting a picture into bit planes, one black-and-white image per bit of each channel, shows where information sits: the top planes look like a rough copy of the photo, the lowest look like noise but still carry some structure in smooth or bright areas. A message written in reading order shows up in the lowest plane as a band of pure noise across the top. The amplified difference between cover and stego, multiplied so that a change of 1 becomes bright, shows the same band. The peak signal-to-noise ratio, PSNR = 10 log₁₀(255² / MSE), measures the distortion: 1 bit per channel gives about 51 dB in the changed pixels, far above the 30 to 40 dB of a good JPEG.
Passwords, and why JPEG wipes the message
Writing the bits from the top makes them easy to locate. With a password, a pseudo-random generator seeded by it shuffles the order of the pixels, so the bits are spread thinly over the whole image and only someone with the password can collect them; the bytes can also be XORed with a keystream. All of this needs a lossless file. JPEG converts the colours to brightness and two colour differences, averages the colour over 2 × 2 pixels, takes a discrete cosine transform of every 8 × 8 block and rounds its coefficients according to the quality: almost every value moves by a few levels, and about half the hidden bits flip. Steganography for JPEG files hides its bits in the rounded coefficients instead, as the tools JSteg, OutGuess and F5 do.
Steganalysis: catching a hidden message
The opponent of steganography is steganalysis, the detection of hidden data. Replacing least significant bits with random message bits leaves a statistical fingerprint: values that differ only in their last bit, such as 100 and 101, become equally frequent. In 1999 Andreas Westfeld and Andreas Pfitzmann turned this into the chi-square attack, which compares the counts of each such pair with their average and gives the probability that the picture has been tampered with. Later methods, such as RS analysis by Jessica Fridrich and colleagues and today's machine-learning detectors, can estimate even a small embedding rate. Hiding well therefore means changing as little as possible and in the least predictable places.
Steganography today
The same ideas are used openly and covertly. Digital watermarks hide the owner's mark in photos, music and films so that it survives copying; many colour laser printers print a faint pattern of yellow dots that encodes their serial number and the date. Researchers have shown messages hidden in the timing of network packets and in the noise of audio. Malware has hidden its code and commands in innocent-looking images on websites and social networks, which is why security tools now look for steganography too.
Explore it
Open the steganography app to hide a message or a small picture in a photo and watch the bits being written pixel by pixel. Compare the cover and the stego picture, look at the bit planes and the amplified difference, add a password, raise the bits per channel until the change shows, run the chi-square attack, download the PNG and reveal it again, and see what a JPEG save does to the message.
Frequently asked questions
What is the difference between steganography and cryptography?
Cryptography makes a message unreadable without a key, but everyone can see that a message is there. Steganography hides the message inside something innocent, such as a photo, so that nobody suspects it. They work well together: encrypt the message first, then hide the ciphertext, so that it is both invisible and unreadable.
How much data can a picture hide?
With the least significant bit of red, green and blue, three bits per pixel: a 12-megapixel photo could hold about 4.5 MB. Using more bits per channel holds more but becomes visible, and a cautious user hides much less than the capacity, because the more bits are changed, the easier the message is to detect.
Does a hidden message survive sending the picture?
Only if the file is not changed. Many messaging apps and social networks resize and recompress pictures as JPEG, which destroys least significant bit messages. Sending the PNG as a file or an attachment keeps every pixel intact.
Is steganography legal?
Hiding information is legal in most countries and is used every day in watermarking and copy protection. What matters is what the hidden content is and what it is used for: steganography does not make an illegal message legal, and some organisations forbid it on their networks.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Open the steganography app