Browsing Tag

Steganography in images


Steganography in Images

December 26, 2012

(Note: I am by no means an expert on this matter, I am simply expressing my personal experience with the subject. For more information Steganography or Google would be a good start)

Steganography is the art of hiding message in such way that no one beside the intended receiver will find (if done correctly). This is by no means a new idea, the history of Steganography can be traced back to the 15 century. For our purposes, I am going to discuss Steganography in the general sense in the computer world, mostly done in Images, but not limited to them. For this example I am only going to consider 256 gray and colored images for simplicity of example, this can be done however with other images and data as well.

How information is stored?

Any computer data today consists of bits of data, 0 or a 1. A bunch of them constitute a byte, which is normally 4 bits. The length of a bit depends on a number of things such as implementation, system, usage and other factors. An image is usually stored as one of two options:

1. Black & White (Grayscale) 
2. RGB colors (Normal)

In both cases the image is built from pixels, or a dot in a 2 dimensional array that has a certain value. In case of option 1 it would be on a scale from 0-255, 0 being black. For option 2 there aren three values that constitute one color as output, Red - Green - Blue, each with the same scale of values from 0 - 255, 0 being black.

How to hide?

So lets say we have the following image (Grayscale) stored in memory as the following pixles:


This would give us an empty 4 X 4 pixel white image. Keep in mind that any of these cell blocks is actually stored in memory as 255 = 11111111 in binary. Now you would agree that the character ‘A’ is equivalent to 65 in ascii which in binary is equal to 01000001. You would also agree that if we change one of these cell values to 254 it would be unnoticeable to the naked eye.

The ‘Magic’ bit...

We are going to store the individual values of A’s binary representation in the least significant bits of the image values. This means we would go over the cell or pixels of the image and change only the last bit of the value, changing the color by only 1. The cells of an image are numbered as follow:


In order for to be stored in memory we will used the first 8 bits, changing the values in the LSB to match to ‘A’. The result will still be a white image, stored in memory like this:


Color and Extraction

The same idea we applied to this example could be applied to an RGB file or any other data type. One could also encrypt the message hidden so even if it is found by anti-Steganography software it would be useless. Based on how you hide the memory you would also need an extraction code. For our example we would simply need to extract and concatenate the first 8 LSB and convert them back to a character, which would give us ‘A’.