Click here to Skip to main content
11,641,224 members (61,812 online)
Click here to Skip to main content

Steganography III - Change only one Bit per Pixel

, 3 Apr 2004 CPOL 154.2K 5.2K 64
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#.

You may also be interested in...

Comments and Discussions

 
Questioni need to hide text inside image without key Pin
sonbolty1-Mar-12 1:10
membersonbolty1-Mar-12 1:10 
AnswerRe: i need to hide text inside image without key Pin
Corinna John1-Mar-12 10:53
memberCorinna John1-Mar-12 10:53 
GeneralRe: i need to hide text inside image without key Pin
sonbolty12-Mar-12 1:49
membersonbolty12-Mar-12 1:49 
GeneralPLEASE PLEASE : I AM BEGGINNER : CAN YOU HELP ME SOURCE CODE FOR stegonagraphy in picture and audio !! Pin
kutomba6-Dec-11 12:58
memberkutomba6-Dec-11 12:58 
Questioni need code of steganography urgently ..... Pin
himanshu199020-Nov-11 19:46
memberhimanshu199020-Nov-11 19:46 
Questionthe length of the bitmap image Pin
174t26-Jun-11 6:23
member174t26-Jun-11 6:23 
QuestionOut image Pin
174t26-Jun-11 2:11
member174t26-Jun-11 2:11 
Generalproject Pin
Member 784332614-Apr-11 20:59
memberMember 784332614-Apr-11 20:59 
QuestionSteganography code in java Pin
Mukesh konde4-Mar-11 18:01
memberMukesh konde4-Mar-11 18:01 
GeneralImage Steganography Pin
Anshuli23-Sep-10 5:21
memberAnshuli23-Sep-10 5:21 
Generalbadly need image steganography source code using java..... Pin
suresh54624-Jul-10 21:03
membersuresh54624-Jul-10 21:03 
Generalimage steganography - embed message in image using LSB Pin
star_light16-Jul-10 17:07
memberstar_light16-Jul-10 17:07 
GeneralModule Pin
vinayanand527-Feb-10 22:19
membervinayanand527-Feb-10 22:19 
GeneralSteganography Code for BMP Pin
pamdee8323-Jan-10 19:19
memberpamdee8323-Jan-10 19:19 
Generalcode required using java Pin
palaash16-Dec-09 4:38
memberpalaash16-Dec-09 4:38 
Generalneed java source code for steganography Pin
prima iman21-May-09 20:22
memberprima iman21-May-09 20:22 
GeneralRe: need java source code for steganography Pin
chaitumad24-May-09 19:49
memberchaitumad24-May-09 19:49 
GeneralRe: need java source code for steganography Pin
speaker1331-May-09 6:53
memberspeaker1331-May-09 6:53 
GeneralRe: need java source code for steganography Pin
cjeniffer10-Mar-12 21:22
membercjeniffer10-Mar-12 21:22 
GeneralI Need Java code for stegnography.... Pin
D.Prasad23-Feb-09 18:57
memberD.Prasad23-Feb-09 18:57 
GeneralRe: I Need Java code for stegnography.... Pin
vijayalakshmi_bnmit21-Apr-09 2:36
membervijayalakshmi_bnmit21-Apr-09 2:36 
GeneralRe: I Need Java code for stegnography.... Pin
chaitumad24-May-09 19:46
memberchaitumad24-May-09 19:46 
GeneralRe: I Need Java code for stegnography.... Pin
puvva26-Dec-10 18:17
memberpuvva26-Dec-10 18:17 
GeneralRe: I Need Java code for stegnography.... Pin
ankit00245-Jan-10 18:56
memberankit00245-Jan-10 18:56 
GeneralImage hiding project Pin
M.Arulraj10-Dec-08 0:04
memberM.Arulraj10-Dec-08 0:04 
GeneralRe: Image hiding project Pin
Corinna John10-Dec-08 7:13
memberCorinna John10-Dec-08 7:13 
Generalimage hiding Pin
rame20-Nov-08 1:15
memberrame20-Nov-08 1:15 
GeneralRe: image hiding Pin
M.Arulraj10-Dec-08 0:41
memberM.Arulraj10-Dec-08 0:41 
GeneralRe: image hiding Pin
wwwwaaaalla7-Mar-10 6:46
memberwwwwaaaalla7-Mar-10 6:46 
QuestionCan anybody have the Base Paper for this Steganograhy -III Pin
pvprasad12-Apr-08 5:39
memberpvprasad12-Apr-08 5:39 
GeneralRe: Can anybody have the Base Paper for this Steganograhy -III Pin
Corinna John12-Apr-08 7:24
memberCorinna John12-Apr-08 7:24 
Generalimplementation USB Token Pin
Parneyan19-Jun-07 18:19
memberParneyan19-Jun-07 18:19 
GeneralSteganografy in java Pin
rafaelvecchio9-May-06 2:51
memberrafaelvecchio9-May-06 2:51 
GeneralRe: Steganografy in java Pin
Corinna John9-May-06 5:45
memberCorinna John9-May-06 5:45 
GeneralSteganografy in java Pin
rafaelvecchio9-May-06 2:46
memberrafaelvecchio9-May-06 2:46 
GeneralRe: Steganografy in java Pin
andre.fiap.br22-Mar-07 10:44
memberandre.fiap.br22-Mar-07 10:44 
GeneralRe: Steganografy in java Pin
chaitumad24-May-09 19:50
memberchaitumad24-May-09 19:50 
Respected Sir,
                     I am also searching for source code for stegnography in core java so please help me about it.my mail id is chaitu1240@gmail.com
GeneralRe: Steganografy in java Pin
andre.fiap.br25-May-09 7:32
memberandre.fiap.br25-May-09 7:32 
GeneralVC6++ HELP HOW Pin
cnncnn18-Aug-04 20:20
membercnncnn18-Aug-04 20:20 
GeneralProblem with PNG Image Pin
lonelywind198221-Jun-04 22:09
memberlonelywind198221-Jun-04 22:09 
GeneralRe: Problem with PNG Image Pin
Corinna John22-Jun-04 20:31
memberCorinna John22-Jun-04 20:31 
GeneralSetting pixel in Bitmap Object Pin
Alexsander Antunes4-Mar-04 6:23
memberAlexsander Antunes4-Mar-04 6:23 
GeneralRe: Setting pixel in Bitmap Object Pin
Corinna John4-Mar-04 20:16
memberCorinna John4-Mar-04 20:16 
GeneralRe: Setting pixel in Bitmap Object Pin
chaitumad24-May-09 19:50
memberchaitumad24-May-09 19:50 
GeneralGetBit/SetBit Pin
jmueller4-Nov-03 21:24
memberjmueller4-Nov-03 21:24 
GeneralRe: GetBit/SetBit Pin
Corinna John5-Nov-03 9:20
memberCorinna John5-Nov-03 9:20 
GeneralRe: GetBit/SetBit Pin
jmueller5-Nov-03 9:30
memberjmueller5-Nov-03 9:30 
GeneralRe: GetBit/SetBit Pin
Corinna John5-Nov-03 9:35
memberCorinna John5-Nov-03 9:35 
GeneralRe: GetBit/SetBit Pin
Corinna John4-Apr-04 21:56
memberCorinna John4-Apr-04 21:56 
Generalavi file Pin
unitecsoft6-Oct-03 8:25
memberunitecsoft6-Oct-03 8: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
Web02 | 2.8.150731.1 | Last Updated 4 Apr 2004
Article Copyright 2003 by Corinna John
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid