Skip to main content

New : Cipher Breaker, the codebreaking assistant, is now on Android Discover

▮ CipherChronicle

Image methods Steganography

Image in an image

Hiding an image in an image rests on one observation: the bits of a pixel are not equally important. The first ones carry most of what you see, the last ones almost nothing. So you keep the best of each image.

How does image-in-image work?

Both images are first brought to the same size. Then, for each channel of each pixel:

  1. Keep the top bits of the cover image (4 by default).
  2. Take the top bits of the secret image (4 as well).
  3. Assemble: cover top bits on the left, secret top bits on the right.
cover  = 1011 0010   (178)
secret = 0110 1001   (105)
result = 1011 0110   (182)
         ↑↑↑↑ ↑↑↑↑
        cover secret

To reveal the secret image, keep only the 4 right-hand bits and move them to the left: 0110 0000, i.e. 96 instead of 105. The recovered image has 16 levels per colour instead of 256, which is plenty to recognise it perfectly.

What does an image processed this way look like?

With 4 bits, the cover stays very close to the original, but a careful eye will spot banding in gradients and sometimes a ghost of the secret image in flat areas. With 2 bits, the cover is intact and the secret becomes a poster with 4 levels per colour.

The setting is a trade-off between two qualities:

Bits given to the secret Cover image Recovered secret
1 or 2 Intact Heavily posterised
4 Slightly degraded Faithful
6 or 7 Destroyed Nearly perfect

What are the weaknesses of image-in-image?

Strengths

  • Maximum capacity: a whole image, not just text.
  • No format, no header: reading cannot fail.
  • A vivid demonstration of what a most significant bit is.

Weaknesses

  • Visible from 4 bits on a smooth cover (sky, plain background). Pick a heavily textured cover.
  • Given away by bit planes: displaying the low planes shows the hidden image directly.
  • Destroyed by JPEG, like any method that writes into low bits.
  • No key: knowing the number of bits is enough.

How do you recover the hidden image?

There is no key to find, only a setting. Display the 1, 2, 3… low bits in turn, stretched across the full brightness range: the hidden image appears as soon as you hit the right number. A single bit plane is often enough to guess its outline.

What are the variants of this method?

  • Uneven split — give 3 bits to red, 3 to green and 2 to blue, since the eye is less sensitive to blue.
  • Greyscale secret — a grey secret needs one channel only: hide it three times, or hide three images.
  • Scrambled secret — run the secret through a pixel permutation first: the bit planes then show nothing but noise.
  • Bit plane — the minimal version: a black-and-white drawing in a single bit.

In CipherChronicle

The workbench fits the secret image to the cover automatically (centred, cropped if needed) and offers 1 to 7 bits. To decrypt, set the same number of bits.

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.