University of Calgary

simple image encryption

Simple Image Encryption
source: Jared Hopf, 2003

Description:

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:

Frog.jpg (18764 bytes)CentreBridge.jpg (68292 bytes)Winter.jpg (92909 bytes)

Will encrypt to something like this when a large enough key file is used:

frogOutEnc.jpg (230238 bytes)CBEnc.jpg (195344 bytes)WinterEnc.jpg (194838 bytes)

However, if the key file isn't large enough or random enough you will get some thing like this:

frogEncBad1.jpg (150820 bytes)CBEncBad1.jpg (140378 bytes)WinterEncBad1.jpg (160451 bytes)

Minimum Requirements:

The program can encrypt/decrypt an image file.

Optional Requirements:

Generation of a random key file if none is provided.

Concepts:

Command line arguments
File I/O
Logical operations on data
Random Numbers
Pointers
Memory Accessing
3D/2D/1D array accessing (Row major access for single dimensional arrays.



Updated: August 10, 2005 11:18 PM