Linked Questions

Popular Questions

Bitwise Operations in a Steganography Program (C)

Asked by At

I'm relatively new to both C and bitwise operations and I'm having trouble with an assignment I've been given in my class. A majority of the code has been given to me, but I've been having issues figuring out a part pertaining to bitwise operations. Once I figure this part out, I'll be golden. I hope that someone can help!

Here is the excerpt from my assignment:

You will need to use 8 bytes of an image to hide one byte of information (remember that only LSBs of the cover image can be modified). You will use the rest of the 16 bytes of the cover image to embed 16 bits of b.size (two least significant bytes of the size field for the binary data), next 32 bytes of the cover will be used to embed the file extension for the payload file, and after that you will use 8*b.size bytes to embed the payload (

What this program is doing is stenography of an image, and I have to modify the least significant bits of the image read in using data from a file that I created. Like I said, all of the code for that is already written. I just can't figure out how to modify the LSBs. Any help would be greatly appreciated!!!

The functions I have to use for reformatting the LSBs are as follows:

byte getlsbs(byte *b);
void setlsbs(byte *b, byte b0);

This is what I've attempted thus far:

/* In main function */
b0 = getlsbs(&img.gray[0])

/* Passing arguments */
byte getlsbs(byte *b)
    byte b0;
    b0[0] = b >> 8;
    return b0;

I'm honestly at a complete loss. I've been working on this all night and I still barely have made headway.

Related Questions