Click here to Skip to main content
Click here to Skip to main content

Steganography III - Change only one Bit per Pixel

, 3 Apr 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
An article about hiding each byte of a message bit-by-bit in eight pixels.

Sample Image - steganodotnet3.png

Introduction

The application described in the last article Steganography II always added visible noise to the carrier bitmaps. This article is about splitting the bytes and hiding each bit in a different pixel. The hidden message is really invisible, because only the lowest bit of one color component is changed.

Background

Before reading this, you should have read at least part one, Steganography - Hiding messages in the Noise of a Picture. This article uses the application described in part one and two, but you don't need the features added in part two to understand this one.

End of the rainbow

Replacing a whole byte of a RGB color produces a rainbow pattern. This is how a white image (all pixels just white) looks like after hiding a text message:

typical colour noise

On a colorful photo, these rainbow pixels may be alright. In grayscale mode, the same message in the same picture looks like this:

typical grayscale noise

As you can see, too many bits of the pixels have been changed. Now, we’re going to spread each byte over eight pixels and make the rainbow disappear.

Get and set bits

spreading a byte over eight pixels

For each byte of the message, we have to:

  1. Grab a pixel.
  2. Get the first bit of the message byte.
  3. Get one color component of the pixel.
  4. Get the first bit from the color component.
  5. If the color-bit is different from the message-bit, set/reset it.
  6. Do the same for the other seven bits.

The C#-functions for getting and setting single bits are simple:

private static bool GetBit(byte b, byte position){
	return ((b & (byte)(1 << position)) != 0);
}

private static byte SetBit(byte b, byte position, bool newBitValue){
	byte mask = (byte)(1 << position);
	if(newBitValue){
		return (byte)(b | mask);
	}else{
		return (byte)(b & ~mask);
	}
}

The rest of the code has not changed much. Hiding works like that now...

hide a message

...and extraction works like that:

extract a message

That's enough text for today. If you want to know the details, you should download the source.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Corinna John
Software Developer
Germany Germany
Corinna lives in Hannover/Germany (CeBIT City) and works as a Delphi developer, though her favorite language is C#.

Comments and Discussions

 
Questioni need to hide text inside image without key Pinmembersonbolty1-Mar-12 2:10 
AnswerRe: i need to hide text inside image without key PinmemberCorinna John1-Mar-12 11:53 
GeneralRe: i need to hide text inside image without key Pinmembersonbolty12-Mar-12 2:49 
GeneralPLEASE PLEASE : I AM BEGGINNER : CAN YOU HELP ME SOURCE CODE FOR stegonagraphy in picture and audio !! Pinmemberkutomba6-Dec-11 13:58 
Questioni need code of steganography urgently ..... Pinmemberhimanshu199020-Nov-11 20:46 
Questionthe length of the bitmap image Pinmember174t26-Jun-11 7:23 
QuestionOut image Pinmember174t26-Jun-11 3:11 
Generalproject PinmemberMember 784332614-Apr-11 21:59 
QuestionSteganography code in java PinmemberMukesh konde4-Mar-11 19:01 
GeneralImage Steganography PinmemberAnshuli23-Sep-10 6:21 
Generalbadly need image steganography source code using java..... Pinmembersuresh54624-Jul-10 22:03 
Generalimage steganography - embed message in image using LSB Pinmemberstar_light16-Jul-10 18:07 
GeneralModule Pinmembervinayanand527-Feb-10 23:19 
GeneralSteganography Code for BMP Pinmemberpamdee8323-Jan-10 20:19 
Generalcode required using java Pinmemberpalaash16-Dec-09 5:38 
Generalneed java source code for steganography Pinmemberprima iman21-May-09 21:22 
GeneralRe: need java source code for steganography Pinmemberchaitumad24-May-09 20:49 
GeneralRe: need java source code for steganography Pinmemberspeaker1331-May-09 7:53 
GeneralRe: need java source code for steganography Pinmembercjeniffer10-Mar-12 22:22 
GeneralI Need Java code for stegnography.... PinmemberD.Prasad23-Feb-09 19:57 
GeneralRe: I Need Java code for stegnography.... Pinmembervijayalakshmi_bnmit21-Apr-09 3:36 
GeneralRe: I Need Java code for stegnography.... Pinmemberchaitumad24-May-09 20:46 
GeneralRe: I Need Java code for stegnography.... Pinmemberpuvva26-Dec-10 19:17 
GeneralRe: I Need Java code for stegnography.... Pinmemberankit00245-Jan-10 19:56 
GeneralImage hiding project PinmemberM.Arulraj10-Dec-08 1:04 
GeneralRe: Image hiding project PinmemberCorinna John10-Dec-08 8:13 
Generalimage hiding Pinmemberrame20-Nov-08 2:15 
GeneralRe: image hiding PinmemberM.Arulraj10-Dec-08 1:41 
GeneralRe: image hiding Pinmemberwwwwaaaalla7-Mar-10 7:46 
QuestionCan anybody have the Base Paper for this Steganograhy -III Pinmemberpvprasad12-Apr-08 6:39 
GeneralRe: Can anybody have the Base Paper for this Steganograhy -III PinmemberCorinna John12-Apr-08 8:24 
Generalimplementation USB Token PinmemberParneyan19-Jun-07 19:19 
GeneralSteganografy in java Pinmemberrafaelvecchio9-May-06 3:51 
GeneralRe: Steganografy in java PinmemberCorinna John9-May-06 6:45 
GeneralSteganografy in java Pinmemberrafaelvecchio9-May-06 3:46 
GeneralRe: Steganografy in java Pinmemberandre.fiap.br22-Mar-07 11:44 
GeneralRe: Steganografy in java Pinmemberchaitumad24-May-09 20:50 
GeneralRe: Steganografy in java Pinmemberandre.fiap.br25-May-09 8:32 
GeneralVC6++ HELP HOW Pinmembercnncnn18-Aug-04 21:20 
GeneralProblem with PNG Image Pinmemberlonelywind198221-Jun-04 23:09 
GeneralRe: Problem with PNG Image PinmemberCorinna John22-Jun-04 21:31 
GeneralSetting pixel in Bitmap Object PinmemberAlexsander Antunes4-Mar-04 7:23 
GeneralRe: Setting pixel in Bitmap Object PinmemberCorinna John4-Mar-04 21:16 
GeneralRe: Setting pixel in Bitmap Object Pinmemberchaitumad24-May-09 20:50 
GeneralGetBit/SetBit Pinmemberjmueller4-Nov-03 22:24 
GeneralRe: GetBit/SetBit PinmemberCorinna John5-Nov-03 10:20 
GeneralRe: GetBit/SetBit Pinmemberjmueller5-Nov-03 10:30 
GeneralRe: GetBit/SetBit PinmemberCorinna John5-Nov-03 10:35 
GeneralRe: GetBit/SetBit PinmemberCorinna John4-Apr-04 22:56 
Generalavi file Pinmemberunitecsoft6-Oct-03 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 4 Apr 2004
Article Copyright 2003 by Corinna John
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid