Ooer.com by Chris Neale

Steganography With GD

Images stored on computers are generally stored in one of two ways. There are indexed colour images, such as GIF and 8bit PNG files, and there are 24bit and 32bit true colour images such as JPG and 32bit PNG. A 24bit image is made up of 3 8bit colour channels, one each for red, green and blue. An 8bit channel is an 8bit integer, it has a range from 0 to 255, 256 different possible values. By combining 3 numbers between 0 and 255 it is possible to represent 16.7 million different colours. This is what makes modern image file formats able to represent photographs and graphics in such a realistic fashion.

Understanding the way images are make up allows us to do something rather clever with them. If you take 256 values you can change a value from 0 to 1 and the user viewing the image will probably be able to perceive a small difference. However, with 16.7million colours such a change from 0 to 1 is imperceivable. This allows us to hide information inside an image without anyone knowing its there. The art of hiding information in plain site is called steganography.

Steganography has many uses in the real world. You can embed a watermark in your photographs that you can use later to prove that you make the images, you can send seemingly innocent email images to friends with secret messages that not even the strictest filter would find, and you can embed messages in your webpages for users to try and find.

The way steganography works in our PHP script is to take a source image and combine into it a message image using the least significant bits of the pixel values. For example, if a pixel is completely black then its pixel values for each channel would all be 00000000. As each channel is 8 bits long there are 8 0s.

If the pixel in our message is black we set the least significant bit to 1. In other words our solid black pixel is now 00000001. The user will not be able to see the change, especially in a photograph, but our decoder will be able to. To extract the message all we need to do is scan through the image and where the least significant bit is equal to 1 we draw a black pixel, and where it is 0 we draw a white one. This will give us a copy of our message picture.

In this script we will use a technique called 'binary shifting'. This is a way of altering numbers in their binary state. If you do not understand binary then follow the link at the end of this article for a tutorial.
In order to hide a message we need to create a message. The easy method of doing this is to create an image file in plain black and white that contains your message.


Now that we have our message we need a source image that we're going to hide a message in. As I am a keen photographer I will be using one of my original images.
Move to page: 1 2 3

Comments

Comments are not currently being accepted for this article.
Sidebar
Published:
21/06/2007
Views:
4437
Author:
Chris Neale
Labels:
Print:
Sidebar:
Wikipedia steganography page
PHP image function reference