Tuesday, April 28, 2009

Steganography with Delphi - Hide Data Inside Images

According to Wikipedia, Steganography is "the art and science of writing hidden messages in such a way that no-one, apart from the sender and intended recipient, suspects the existence of the message, a form of security through obscurity".

In computer terms, steganography means hiding a message within a larger one in such a way that others cannot see the presence or contents of the hidden message.

Interested in how to code a Delphi application to hide data inside an image using cryptography - steganography?

StegaImage - Steganography with Delphi
StegaImage is a little Delphi application to hide files (information) inside crypted images.
Take a file, hide it inside a BMP image, and that's all. All you get is a new image that looks like the original, but it has the data hidden inside it.

How does StegaImage work?
In a 24-bit bitmap, each pixel is made up of a 24-bit number. Each number is composed of three 8-bit numbers (the R, G and B channels). These are the intensity of the Red, Green and Blue colors that create the final color of the pixel.
To hide something inside the image, we will replace the Least Significant Bit (this is, the "rightmost" bit) of each 8-bit channel of every pixel, with the bits of the file we want to hide.

The image will lose some quality because now the colors of the pixels are not the same, but it will go unnoticed to the human eye.

Obviously, since we are storing only 3 bits per pixel, the image must have a phenomenal size to accommodate just a tiny little file.

For example, if we want to hide 1 MB of data, we need an image with 2,796,203 pixels, which would have a size of something like 2,200 x 1,320 pixels. And that is a 8.3 MB file!
We could replace the 2, 3 or 4 rightmost bits of every channel in order to increase the amount of data we can hide, but the quality could decrease considerably.
Try 8 bits per channel and you'll see what I'm talking about (amazingly, 7 normally produces intelligible - although very ugly- images).

No comments: