Techniques - DevSource
DevSource: Microsoft Developer Resource DevSource Home Sponsored by Microsoft Home Add Ons Architecture Languages Techniques Using VS Forums
Home arrow Techniques arrow Page 2 - Digital Disappearing Ink: Steganography in C#
Digital Disappearing Ink: Steganography in C#
By Rick Leinecker

Rate This Article: Add This Article To:

Digital Disappearing Ink: Steganography in C# - ' Hiding Messages in RGB '
( Page 2 of 4 )

Images">

Hiding Messages in RGB Images

This article will talk about RBG images as Steganography carriers, and simple text messages as the payload. We'll use the BMP file format. And since the .NET framework saves BMP files as RGB images plus alpha bytes, I'll be talking about bitmap files having four bytes of data for each pixel in the image. In other words, each pixel has a byte with a red value, a byte with a green value, a byte with a blue value, and a byte with an alpha value.

ADVERTISEMENT

For more information about image processing, see the article Image Processing in C# here on DevSource.com.

Please note that GIF images have palette-indexed pixel values, which requires an entirely different approach then we're going to present. JPEG images pose a different challenge than the GIF images since they undergo lossy compression when they're saved. If we used the approach that will be used in this article for JPEG images, part of the message data would be lost. At a later time, I'll write articles that solve the GIF and JPEG issues.

Once again, each pixel's color is determined by four bytes of data. And each byte of data has eight bits. In almost every case, the least significant bit can be removed (and just made 0) without the slightest perceptible difference. The following two images show the original followed by an image with the least significant bit masked off.

In fact, there is a theory known as "Just Noticeable Difference" (JND) that says small changes won't be noticed. Removing the least significant bit from each data value amounts to less than one half of a percent of the pixel's color definition.

For many images, more than one bit can be discarded without a noticeable difference. Images that lend themselves to the loss of more than one bit of data tend to have solid shapes and at least a mid-level brightness.

Making Room For Data

With one or more bits discarded, there is room for hidden data. The more bits that are removed, the more room that exists for data. Since the least most significant bit doesn't perceptually alter the image, it can be set or not set without notice. The least significant bit(s) can be used to store the hidden message. The image into which the message is hidden is known as the carrier, the text message that we'll hide is the payload.

Hiding the Data

Text can be hidden in the least significant bit of the carrier image, one bit at a time. The letter 'A' is 01000001 in binary. In order to hide the 'A' character in the carrier, the first low bit in the carrier will be 0, the next 1, the next 0, the next 0, and so forth until the entire letter is hidden.

An Illustrated Example

Here is a set of illustrations that will show the principle of hiding a text message in bitmap data.

The Original Image

Image:

First Two Pixel Decimal Values

R1G1B1A1R2G2B2A1
7612320525582129211255

First Two Pixel Binary Values

00110111
11111011
01010001
01011011
11110001
00110001
11011011
01110111<-- Need To Delete Row

Least Significant Bit Dropped

Image:

First Two Pixel Decimal Values

R1G1B1A1R2G2B2A1
7612220425482128210254

First Two Pixel Binary Values

00110111
11111011
01010001
01011011
11110001
00110001
11011011
00000000<-- Bits All Zeroed Out

The 'A' Character Hidden

Image:

First Two Pixel Decimal Values

R1G1B1A1R2G2B2A1
7612320425482128210255

First Two Pixel Binary Values

00110111
11111011
01010001
01011011
11110001
00110001
11011011
01000001<-- Data Set to 'A' (01000001)



 
 
>>> More Techniques Articles          >>> More By Rick Leinecker
 



DevSource video
Devsource Video Series
Manipulating Society through Technology
Jeremy Bailenson, Director of the Virtual Human Interaction Lab at Stanford University, talks about virtual reality, avatars, Moore's law, how real world behaviors influence online reality, and societal manipulation through technology!
>> Play video
>> Read article
>> See all videos
DevLife Blog

Julia explores the Robotics Studio! (It's for more than you think.)

MSDev Blog

Messages for Bill Gates!

Make it Work
.NET makes runtime type checking a breeze. See what Peter has to say about it in this week's tips!
News
Microsoft Counts on App Support for Vista
Microsoft has taken pains to demonstrate that Windows Vista will have ample application support.
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.