program




Your goal (for the encode portion): to write a program that will:

1. read three command-line arguments, the first is the image we wish to hide a file in, the second is the filename of the file we wish to hide, the third is the filename that we will write the hidden image to.

2. copy the original image to an array

3. create new pgm file to hold changed image

4. allocate memory for the new image data

5. start at the mask image’s 0,0 pixel

6. for each bit in the hidden file

a. drop the least significant bit from the mask image current pixel value

b. add a 1 to that pixel value if the corresponding hidden file bit is a 1

c. add a 0 (or don’t) to that pixel value if the corresponding hidden file bit should be a 0

d. move to the next pixel in the image (the next column in the image, or the next row’s 0th column if at the max column has been reached)

7. write an EOF character in the next 8 image pixels

8. save the array to a file using the pgm image format we’ve been using for the prior projects



Your goal (for the decode portion): to write a program that will:

1. read two command-line arguments; take the first command-line argument which is the filename of an image (we will provide two pgm images to test with)

2. read that image from the provided filename to an array

3. open the decoded file with the second command-line argument as the filename

4. for each pixel in the image

a. if the last bit is zero

i. make the next corresponding bit in the hidden file a 0

b. if the last bit is one

i. make the next corresponding bit in the hidden file a 1

5. write each decoded byte to the decoded file