Steganography
How a message can hide inside an ordinary picture by changing the last bit of each pixel value: how much fits, how it gets detected, and why it is paired with encryption.
In 30 seconds
Steganography hides the fact that a message exists. Encryption scrambles a message but leaves it obvious that something secret is being sent; a picture with hidden data just looks like a picture.
The classic method rewrites the least significant bit of each pixel value. That changes a colour by at most one step in 256, which no eye can see.
It is not undetectable: statistics can reveal the tampering. So the message is encrypted first, and hiding is the second layer.
Steganography, step by step
The worked example uses one number per pixel. Plain last-bit hiding only survives in lossless formats such as PNG; JPEG compression would erase it, so tools for JPEG hide data in a different way.
- Step 1: Hide it, or scramble it. Encryption turns a message into gibberish, but the gibberish is in plain view: anyone watching knows a secret is being sent. Steganography aims at something different. It tucks the message inside something innocent, here a holiday photo, so a watcher has no reason to look twice.
- Step 2: A pixel is a number. A digital picture is a grid of pixels, and each pixel stores its colour as numbers from 0 to 255, eight bits apiece. The bits are not equally important. Flipping the first bit moves the value by 128, an obvious change. Flipping the last one, the least significant bit, moves it by 1, which nobody can see.
- Step 3: Write into the last bits. To hide the letter A, write its code, 65, as eight bits and take eight pixels. The last bit of each pixel is replaced by one message bit. Six of these pixels already end in the right bit and stay as they are; two change, each by a single step. On average about half the pixels need changing.
- Step 4: Bob reads the last bits. The picture travels in the open. Bob, who knows the method, reads the last bit of each pixel in order, gets 01000001, and turns it back into the letter A. He does not need the original picture, only the agreed rule for which pixels to read. Careful tools choose the pixels with a shared secret key.
- Step 5: How much fits. A colour pixel holds three numbers, for red, green and blue, so it can carry three hidden bits. A 1000 by 1000 photo offers 3 million bits, or 375,000 bytes: one eighth of the raw image, roughly 200 pages of plain text. Using two bits per number doubles the room but disturbs the picture more.
- Step 6: Detection: steganalysis. Invisible is not undetectable. Embedding only ever turns a value into its neighbour: 180 into 181, or back. Random-looking hidden bits therefore even out the counts of each such pair, which ordinary photos rarely do. Steganalysis is the search for statistical fingerprints like this one, and it needs no human eye.
- Step 7: Encrypt first, then hide. The two tools answer different questions, so they are used together. Encrypt the message first, then hide the result. If nobody notices the picture, steganography has done its job. If someone does extract the bits, they find only ciphertext, which is useless without the key.
Try it yourself
Learn this first
Spotted a mistake on this page?