31-01-2013, 04:33 PM
Steganography Application
1Steganography.pdf (Size: 67.48 KB / Downloads: 42)
Overview:
People use cryptography to send secret messages to one another without a third
party overseeing the message. Steganography is a type of cryptography in which
the secret message is hidden in a digital picture. Think of all those pixels in an
image and each pixel has three color numbers — there are zillions of numbers
in an image. If you were to change a few of these color numbers the resulting
picture would probably look a lot like the original image; in fact, most people
probably couldn’t tell that you had changed the image at all. Steganography works
by changing a few pixel color values; we will use selected pixel values to represent
characters instead of a color value. Ofcourse, the resulting image will still look
mostly like the original except that a few tiny ”blips” might seem a little out of
place if you look very closely. We can then send the image to a buddy and they can
extract the message if they know which pixels to decode.
Bitmap Files
• First you will need to read your picture as a jpg and then save it in 24-bit bmp
format. You will need to use bmp files for this assignment because jpg’s are
”lossy” meaning that what you write to the file may be changed slightly so
that the resulting image can be stored more efficiently. Thus jpg will not
work for steganography because jpgs will change the secret message when
storing the file to disk. Here are the commands to save your file. You can
give it the same name except be sure to put a .bmp file extension on the end.
(For example, I loaded ”Matt.jpg” and then saved ”Matt.bmp”).
Interaction
• Prompt the user if they want to encode or decode a message.
• Use the FileChooser dialog to prompt the user for an input file.
• If encode, prompt the user for an input message. Encode the message into
the picture (details below). Then use the FileChooser dialog to prompt the
user for an output file. Save the new picture/message in this file (using bmp
format).
• If decode, extract the message from the file. Print the message.
Encoding/Decoding Method
• You can extract the pixels of your target picture in one big array using the
textttgetPixels() method.
• Use the first pixel (at spot 0) to hide the length of your message (number of
characters). You will limit yourself to messages that are between 0 and 255
characters long.
• After that use every eleventh pixel to hide characters in your message. Start
at pixel 11, then pixel 22, and so on until you hide all characters in your
message.
• Every thing that you need to hide in a pixel is 8-bits long. The length (in the
first pixel) is a byte. You can typecast all the unicode chars to bytes as well.
• Use the method below to hide each byte in an appropriate pixel.
Hiding Method
The problem with changing the red values in our encode/decode steps, is that
these often cause quite visible changes in the resulting image. This is especially
true if the pixels that are being changed are part of a large section of uniformly
colored pixels – the ”dots” stand out and are noticeable. As an option, we can
change only the lower order bits of each pixel color (red, blue, and green). This
will make subtle changes to each pixel’s color and will not be as evident.
Remember that each pixel has three bytes: one byte for red, blue and green
colors. Each byte has 8 bits to encode a number between 0 and 255. When we
swap out the red color byte for a character, it is possible that we are changing the
redness of that pixel by quite a bit. For example, we might have had a pixel with
values of (225, 100, 100) which has lots of red, some green and some blue – this is
basically a reddish pixel with a slight bit of pink color to it. Now suppose we are
to store the character ”a” in the red part of this pixel. An ”a” is encoded as decimal
number 97 so our new pixel becomes (97, 100, 100). Now we have equal parts of
all three colors to produce a dark grey pixel. This dark grey is noticeably different
than the dark pink we had before; it will definitely stand out in the image especially
if the other nearby pixels are all dark pink.