Due Dates:
Individual Test Cases: Tuesday, April 8 midnight
Team Test Cases: Wednesday, April 9 during lab
Individual Design: Tuesday, April 15 midnight now Tuesday April 22
Team Design: Wednesday, April 16 during lab now Wednesday April 23
Individual Source: Sunday April 20 midnight now Sunday April 27
The educational goals of this program are to use the concepts of
Steganography is the art of concealing a message in a medium. That's a very general definition. People have implemented it in many many different ways. There is a list of resources at the bottom of the assignment for more reading if you want. Today it is being implemented on computers. Messages are stored in picture files, word processing documents, sound files, just about every kind of file that exists. Generally it is relying on "security by obscurity". The fact that there IS a message is not at all obvious, so no one searches for it. Obviously that is not the safest assumption. Usually messages to be inserted/hidden in files are first encrypted by secure methods, then inserted. Even if someone knows there is a message in the file, after they extract it, they still have a mishmash unless they can also decrypt it.
There are many algorithms for steganography. The algorithm following is similar to some real ones, but it is simpler. Steps are given first, then a worked out example. Note that this one is also a simplified version of the final algorithm you will implement, but it is the place to start.
As an example, here is a "before and after" capture of two image files. One of these pictures has a message embedded in it. Can you tell which one? Hint: look at the filenames.
Algorithm for inserting a hidden message into a file
Example of insertion of a message into a file:
This method can be used to insert a message of any length into the data in your file, only limited by the size of the file. Any ASCII character can be used, not just letters of the alphabet.
Algorithm for Extraction of a message from a file
Basically the insertion method is reversed.
Example of extraction
One note about this method: The information that was discarded from the numbers when the message was inserted (the original ones' digits) is not restored by the extraction method. That is not a major drawback of the method.
Write a program which ask the user whether they want to insert a message or extract a message. If they say insert, then the program asks for a filename and a message. The program will then produce another file named "secret" which will contain the message hidden as described above. If they say extract, the program asks for filename. It then proceeds to extract the hidden message inside.
A Sample Run
Steganography Assistant Do you want to insert a message or extract one (I/E)? I Inserting a message Filename? blocks.ppm Message? This is a test Done insertion Thanks for your businessThe program accepts the filename and the message and inserts the message into the data in the file. A new file is created with a name "coded-blocks.ppm". See the other example below for samples of what is in the original file and the coded file.
Another Sample Run
Steganography Assistant Do you want to insert a message or extract one (I/E)? E Extracting a hidden message Filename? coded-blocks.ppm The length of the message is 14 The message is This is a test Thanks for your businessThe program took in a file called coded-blocks.ppm and extracted from it "This is a test". To be helpful the start of the file that contains the message is included here - it is not actually output by the program to the screen. Note that this is a PPM file, it has the header at the start. The image was 38 pixels wide and 36 pixels tall, with a maximum color value of 255.
P3 38 36 255 250 255 255 251 252 252 254 251 251 250 255 255 258 255 255 254 255 255 241 249 249 240 249 249 254 255 255 241 249 249 250 255 255 255 250 250 251 255 255 251 250 250 255 250 250 250 255 255 253 255 255 242 251 255 251 249 255 250 248 255 255 234 255 251 242 255 251 245 253 255 246 243 250 253 241 253Compare this to the original file, blocks.ppm, before the message was inserted. Note that the original file does have newlines in the file at the end of every row of the image. This is not required for our purposes. It is ok if your coded file does not have them, as long as the values are separated by whitespace of some kind.
P3 38 36 255 255 255 255 252 252 252 251 251 251 255 255 255 255 255 255 255 255 255 249 249 249 249 249 249 255 255 255 249 249 249 255 255 255 250 250 250 255 255 255 250 250 250 250 250 250 254 255 255 251 255 255 249 251 255 253 249 255 255 248 255 255 234 255 255 242 255 255 245 253 255 246 243 255 253 241
Another Sample Run
Steganography Assistant Do you want to insert a message or extract one (I/E)? a Please enter an I or an E Do you want to insert a message or extract one (I/E)? k Please enter an I or an E Do you want to insert a message or extract one (I/E)? R Please enter an I or an E Do you want to insert a message or extract one (I/E)? i Inserting a message Filename? who File will not open Filename? nofile File will not open Filename? File will not open Filename? one.ppm Message? Hello Done insertion Thanks for your business
This shows some of the data validation being done.
Testing
READING: You should read a page on Testing Files. This will give you some ideas on how to test programs which use files.
Read the assignment carefully. Look at how the program is supposed to behave. You do not know what the code looks like yet - that is fine. Look at the example run given. Consider places where the program can have a bug.
NEW DO THIS FIRST!
Make a test plan for this program.
Save this doc file
and fill in the table with test cases.
You should have a total of 14 non-redundant cases.
Put your name and the section at the top.
Specifications
There are some specifications that your program needs to meet. These will affect the design and the implementation.
Your program must have and use the following functions (in addition to the main function):
Design
Decide on what steps you
will need to perform to solve this problem.
Write the steps in pseudocode (NOT Python!) in comments in a Python file.
Save this Python file as "design3.py".
There should be at least 16 steps in the design. This does count each step inside the loops separately. You MUST state all the control structures you will use to solve this problem.
Your design must have separate headers for EACH function that you write, as usual, including pre- and post-conditions, etc.
Read an introduction to the PPM format (Portable Pixmap).
Why? because steganography is often inserted into image files or audio files. The modern formats for these kinds of files are fairly complicated to deal with (binary). But PPM is a format which can be used and manipulated pretty easily. The file is actually a text file! A PPM image file can actually be created by something like Notepad. So this is added to the assignment. The data files used for insertion and extraction will not just be runs of numbers; they will be actual images. You can see that the PPM format calls for a small header at the start of the file. This can be ignored when you read the file. The numbers after the header are triples representing the RGB values of each pixel. You will do your insertions into the R number of each RGB triple.
This change should be doable with MINIMAL changes to the code you have already written!
More discussion will appear here soon. More discussion about PPM
One nice thing about the header info of a ppm file is that it includes two numbers which indicate the number of columns of pixels in the picture and the number of rows (how wide it is and how tall it is). We don't need to deal with these numbers for display purposes, but you could use them to calculate how many pixels are in the picture and determine if the message will fit or not. If the message doesn't fit, you can cut the message off so it will fit, and tell the user that the message was truncated.
Implement the design
Individually write a Python program to implement your design.
Start with a copy of the Python file you have that has
the design in it (possibly updated with improvements
you or your team came up with) and write your Python code between
the commented lines of the design.
Make sure you eliminate any syntax and semantics errors.
Here is where test cases come in handy!
Verify that the program does come out with the correct behaviors.
Please read the documentation standard on the class web page. As you can see from looking at the grading page, we will be looking to see how you meet these standards. Note particularly that we require a header comment!