Question: Having trouble writing this small C program: A program in C (NOT C++) that accepts command line arguments (see below), that reads a sequence of

Having trouble writing this small C program:

A program in C (NOT C++) that accepts command line arguments (see below), that reads a sequence of bytes and outputs the sequence XORed with a mask. The mask acts as an encryption key. If the output of this program is then fed into this program with the same mask, the original stream of bytes should be produced. Command line arguments to the program are: -i ..................input file name (default: stdin) -o .................output file name (default: stdout) ..........................The mask. Must be provided and less than 10 characters. For example, if the mask is 12 and the data is abcd, then a is xored with 1, b is xored with 2, c is xored with 1, and d is xored with 2. This should produce the output string PPRV (or the output byte stream 0x50, 0x50, 0x52, 0x56 (80, 80, 82, 86 in decimal)). Note that NOT every output stream will be printable ASCII characters.

REQUIREMENT: Use only system calls for all input and output operations, including any error messages that may be output (sent to stderr). The data should be from either a file or stdin and the output should be to either a file or stdout.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!