# Hiding text string with steganographic method - practical problem

I'd like to ask for small hint with following problem:

Using the steganographic method of the least significant bits, hide the text string "Kra" in four pixels of color with RGB code . Hide the text in the sequence of bits of the image one character at a time, ie first hide the character "K", then the character "r" and at the end of the sequence of image bits "a" will be hidden. The text is encoded according to the Latin-2 character set, so "Kra" = . Write the resulting pixel values in the format .

I assume that (128)10=(10000000)2, individual characters converted from decimal to binary system as following:

• (4B)16 = (01001011)2
• (72)16 = (01110010)2
• (61)16 = (01100001)2

At this point, I can start substituting bits in (128)10 values of R, G and B, starting at the least significant bits. However, I will get something like this:

• R=(11001011)2=(203)10
• G=(11110010)2=(242)10
• B=(11100001)2=(225)10

and this is quite far from the original (128)10 values and it does not even meet the condition of unrecognizable color difference by the human eye. In addition, the last 4th pixel remains unused.

What's wrong with that method? Thank you for your explaination.

Why it doesn't work

With LSB steganography, only 1 bit of the secret is inserted in each byte of the innocuous data, so as to not change it perceivably. You can use more, as you did, but as you can see the output is clearly far from the input image. This is why it is named least significant bit (singular.)

Each pixel is made of 3 bytes (R,G,B), so each pixel can only store 3 bits of your secret. With 4 pixels, you can hide up to 12 bits, and you have 24 bits to hide. You would need at least 8 pixels to hide it or modify the 2 least significant bits, so it doesn't work.

I believe your problem does not require you to hide all 3 characters ("Kra") in a single sequence of 4 bytes, but to do it 1 time, each time hiding 1 character. I will explain how you can do it character by character (using 3*4 pixels), or by optimizing your method and using only 8 pixels.

Hiding K

As you said, with the designated encoding we have `K = (01001011)2`

``````Pixel 1:
10000000 -> 10000000
10000000 -> 10000001
10000000 -> 10000000
Pixel 2:
10000000 -> 10000000
10000000 -> 10000001
10000000 -> 10000000
Pixel 3:
10000000 -> 10000001
10000000 -> 10000001
10000000 -> 10000000 (unchanged)
Pixel 4:
10000000 -> 10000000 (unchanged)
10000000 -> 10000000 (unchanged)
10000000 -> 10000000 (unchanged)
``````

You could do it 3 time, for each letter.

Hiding everything

As you can see, there's some unused space if you do it separately. You could keep hiding the next letter in pixel #3, and adding more pixels. I'll just post the end results here:

``````10000000 10000001 10000000
10000000 10000001 10000000
10000001 10000001 10000000
10000001 10000001 10000001
10000000 10000000 10000001
10000000 10000000 10000001
10000001 10000000 10000000
10000000 10000000 10000001
``````

As we saw before, 8 pixels are enough if we hide the secret bit by bit. We could make it all fit into the 4 pixels, but that would require to hide twice as much bit (2) in each byte...

Hiding everything.. in 4 pixels

The process is identical as before, except that instead of hiding the secret by replacing the last bit, we will replace the last 2 bits :

``````10000001 10000000 10000010
10000011 10000001 10000011
10000000 10000010 10000001
10000010 10000000 10000001
``````

This time, it fits into 4 pixels, but the image will be further from the original. (Although still imperceptible to me.)

Original image

Image with 'Kra' hidden:

Your "Kra" is hex 4B 72 61

You have 24 bits of information to steg into your image.

You have 4 24-bit pixels of hex 80 80 80 to work with, or 12 color elements of hex 80.