Image methods Steganography
LSB (least significant bits)
LSB (Least Significant Bit) is the entry point to image steganography. The idea fits in one sentence: in a pixel, the last bit of each colour changes almost nothing you can see, so it can be replaced with something else.
How does LSB work?
Every pixel is described by three numbers from 0 to 255: red, green, blue. In binary, each takes 8 bits. The rightmost bit is only worth 1: going from 200 to 201 in red is imperceptible.
- Convert the message into a stream of bits (UTF-8 here, so accents and emoji work).
- Prefix it with its length, on 32 bits, so the reader knows where to stop.
- Walk through the pixels left to right, top to bottom. For each R, G, B channel, replace the last bit with the next bit of the message.
Example on one pixel, hiding the bits 1 0 1:
R = 200 = 1100100[0] → 1100100[1] = 201
G = 117 = 0111010[1] → 0111010[0] = 116
B = 64 = 0100000[0] → 0100000[1] = 65 To read the message, read the last bits back in the same order: the length first, then the text.
A 600 × 400 image offers 720,000 bits, about 90,000 bytes: plenty of room for several pages.
What does an image processed with LSB look like?
Like the original. Each colour moves by at most 1 out of 255, or 0.4%. No screen and no eye can tell the difference, which is the whole point.
The trace only shows when you isolate bit plane 0: in a photo it looks like noise that loosely follows the shapes; where a message was written, it turns into perfectly uniform noise, often confined to the top of the image.
What are the weaknesses of LSB?
Strengths
- Invisible to the naked eye, even on a flat colour.
- High capacity: 3 bits per pixel, up to 12 when using 4 bits per channel.
- Simple to program and to check by hand.
Weaknesses
- No resistance to JPEG. Lossy recompression rewrites precisely the low bits: the message is destroyed. Use PNG, sent as a file.
- Statistically detectable. Writing bits evens out the counts of each pair of neighbouring values (200 and 201, 202 and 203…). The chi-square attack and RS analysis measure this and even estimate the message length.
- No secrecy without a key. Anyone who suspects LSB can read the message: the method hides, it does not encrypt.
How do you recover an LSB message without the key?
- Display bit plane 0 of each channel: a patch of overly regular noise gives data away.
- Read the bits in natural order and try the usual conventions: length header, null-terminated text, 1 or 2 bits per channel, RGB or BGR order.
- If a keyed traversal was used, the bits are there but out of order: you need the key, or a good guess.
Tools such as zsteg or StegSolve automate these attempts; they are CTF staples.
What are the variants of LSB?
- n-bit LSB — use 2, 3 or 4 bits per channel. Capacity grows accordingly, but at 4 bits the change (up to 15 out of 255) becomes visible in gradients.
- Keyed traversal — a key sets the order of the pixels used. The message is spread across the image instead of sitting at the top.
- LSB matching — add or subtract 1 instead of overwriting the bit, to defeat statistical analysis.
- Alpha channel — write into transparency instead of colours.
In CipherChronicle
The image workbench offers LSB with 1 to 4 bits per channel and an optional traversal key. A live counter shows how many bytes the image can hold. The output is always an opaque PNG.
Demonstration
The CipherChronicle artwork is encrypted then decrypted right here, in your browser, with the same engine as the workbench. Drag the bar to compare.