10-05-2012, 02:57 PM
Steganography Application
Steganography.pdf (Size: 67.48 KB / Downloads: 61)
Skills covered in this assignment:
Here are some of the skills you will need to learn in order to complete this
assignment:
• Loading and saving bitmap files.
• Bit manipulation operations.
Requirements
• Project is to be submitted on email by 11:30am on Monday, May 1.
1
• You are to create an application called Steganography.java. All your
code will be in this file. This is what you will submit on email.
• Your project is to work with the standard (original) Picture.java class.
You shouldn’t need any changes to this class in order to make your project
work. You will not be submitting a Picture.java file. Instead, I will use
my copy to run your program.
• There is a file Secret.bmp on the class web page. Encoded in this file is
a question. Use your program to decode the message. Answer the question
(in 255 chars or less). Then submit back to me your response encoded in a
different bmp picture. You are to copy this bmp file in your file on the shared
drive (before 11:30am, May 1). Of course, make sure your own program can
decode the response you put in this picture; that way you can be sure that my
program can decode the response too.
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”).
> Picture p = new Picture(FileChooser.pickAFile());
> p = p.halve().halve();
> p.saveBMP(FileChooser.pickSaveFile());
• There is also a loadBMP method. You can probably guess how this works.
• Note that I reduced my image to 1
4 original size because bmp files take a
lot of memory. You will run in to less trouble if your image is smaller (say
100x100 or less).
Bit Manipulation
• You will need to be able to manipulate the bits stored in numbers. There are
three basic bit manipulation operations: and, or, and shift. You will need all
three.
• See the BitExample.java example to see how to use these different
operations.
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.