To test understanding of I/O (input output) functions for file handling, and to use the bitwise operators.
This program consists of two parts: encryption of a file, and decryption of a file that has been previously encrypted. Encryption is the process of rendering a text file unreadable by humans, yet by applying the process in reverse (decryption) the file can be recovered in its original state.
It may be implemented by two functions, one to do the encryption, and the other to do the decryption. The main program should accept the following as part of the command line:
The program should check the arguments on the command line and give help to the user as to how to run the program if there are insufficient arguments, or any incorrect ones.
So, if you compile your program using command:
% gcc -o crypt cryption.c
(assuming your C program is in the file cryption.c), to encrypt an input text file named tfile and store the encrypted output as efile, you could type the
command:
% crypt e password tfile efile
(where password is the password for encryption, and e indicates encryption is to be done)
Subsequently, you will run the program again to decrypt the encrypted file as input (using the same password); you should get the original text file back as output.
% crypt d password efile tnewfile
where password is the password for decryption, and d indicates decryption is to be done.
Note : after the two runs of the program: the contents of tnewfile should be IDENTICAL to that of tfile. An easy check for this is to use the UNIX program diff:
% diff tnewfile tfile
This should produce no messages, since a message of any kind indicates a difference between the two files.
April 30th., 5:00pm. Mail your completed source code to the grader, (login salahmed). Hand in the hard copy version to me (RTH), together with a hard copy version of the output.