Sunday, May 2, 2010

Steganography in Java

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. (Source: Wikipedia)

The image into which the message is to be hidden is known as the Carrier Image and the message or the file to be hiden is known as the payload.Each bit of the payload is hidden in the Least Significant Bit of either Red, Green and Blue for each pixel.That means we can hide 3 bits of payload per pixel.

Example:

In this example we will hide the letter 'A' (in binary 01000001)

Assume the three carrier pixels in RGB

R: 0011100 0
G: 0110100 1
B: 0000111 1

R: 0011010 0
G: 1000100 1
B: 0010001 0

R: 0011110 0
G: 1000010 0
B: 0011111 0

Here, we change the least significant bits (01101000) to our payload (01000001).
After this, our carrier pixels will be changed to

R: 0011100 0
G: 0110100 1
B: 0000111 0

R: 0011010 0
G: 1000100 0
B: 0010001 0

R: 0011110 0
G: 1000010 1
B: 0011111 0

The difference between 00001111 and  00001110 in the value for blue intensity is likely to be undetectable by the human eye.