08.21.17 - 12.17.17
Program can correctly encrypt a clear text file | 30 pts |
Program can correctly decrypt a crypt text file | 30 pts |
Program uses a cipher from file | 20 pts |
Program handles specified errors | 20 pts |
Total | 100 pts |
According to Wikipedia "In cryptography, a substitution cipher is a method of encoding by which units of plaintext are replaced with ciphertext, according to a fixed system; the "units" may be single letters (the most common), pairs of letters, triplets of letters, mixtures of the above, and so forth."
For this lab you will write a C program that will be able to encrypt text files with a substitution cipher or decrypt text files that have previously been encrypted with a substitution cipher.
The user of this program should be able to execute the program from the command line and should be able to provide all of the information the program needs in the form and command line arguments and files. The basic form of the command the user should be able to execute is:
program_name <cipher_file> <encrypt|decrypt> <clear_text_input_file.txt | crypt_text_input_file.txt> <clear_text_output_file.txt | crypt_text_output_file.txt>
In this command:
Examples of some commands:
a cipher.txt encrypt clear_text.txt crypt_text.txt
This command would run the program called 'a' using the cipher contained in the file cipher.txt to encrypt the content of the file called clear_text.txt and would store the encrypted output into crypt_text.txt
./a.out cipher.txt decrypt crypt_text.txt clear_text.txt
This command would run the program called 'a' using the cipher contained in the file cipher.txt to decrypt the content of the file called crypt_text.txt and would store the decrypted output into clear_text.txt
The cipher itself will be stored in a file where every letter of the alphabet is matched with a 'converted' letter it matches up with. If in your substitution cipher the letter A was changed into the letter X then the line:
A X
would appear in the cipher file with a space separating the two letters (space delimited). An example of a cipher file is attached at the bottom of the assignment.
If the sample command above was executed:
a cipher.txt encrypt clear_text.txt crypt_text.txt
and the clear_text.txt file contained:
THIS IS A SAMPLE FILE
THAT HAS SOME SAMPLE TEXT
IN IT.
THIS IS SOME EXTRA
Then after the command was run the file called crypt_text.txt would contain:
URFK FK Q KQYBAO SFAO
URQU RQK KXYO KQYBAO UOGU
FL FU.
URFK FK KXYO OGUMQ
The program should gracefully handle the following issues: