simple image encryption
The purpose of this assignment is to create a simple program that will encrypt a given ppm image file.
The program will utilize a simple method for encrypting the image data. The method is using the logic expression XOR. XOR generates the following truth table.

The nice thing about XOR is that if you XOR a section of data with the same key code two times it will return to its original state. So the first XOR will encrypt something, while the second one will return it to normal.
Another thing that will be needed for this assignment is a key file. A key file is a file that provides will provide the codes for the program to XOR against the image data. A good key file will just be a sequence of random characters to provide a good enough encryption. Another thing, the key file should be at least half as large as the image to encrypt, so that there is a harder chance for the encryption to be broken and for the image to properly encrypt.
Some examples:
Will encrypt to something like this when a large enough key file is used:
However, if the key file isn't large enough or random enough you will get some thing like this:
The program can encrypt/decrypt an image file.
Generation of a random key file if none is provided.
Updated: