problem 1) prepare the program which compute the CRC-16 value for a given file and also verifies the correctness of a given file that already has CRC-16 value appended at the end, as more fully described below.
Use the CRC polynomial x^(16) + x^(11) + x^(8) + x^(7) + x^(3) + x^(2) + 1.
1) The program should compile from the command line.
2) The program executable file name must be “crcfile”.
3) The program should run from the command line and take two (2) command line parameters.
4) The first command line parameter would be a flag value which identifies the mode of operation: “c” for calculating a CRC value, or “v” for verifying a CRC value. Only these two values are allowed. Any other values must produce a simple error message and a graceful exit from the program.
5) The second command line parameter would be the name of the file to be examined. The file must be a text file that is in the same folder as the program executable. If the file is not found, the program must issue a simple error message and exit gracefully.
6) The program must direct all output to the command window (terminal) screen. The details of what to output are describeed below.
Specific Functions inside code:
You should implement the following functions/methods:
• A function/method for converting a hexadecimal string into binary string
• A function/method for converting a binary string to hexadecimal
• A function/method to validate the characters in the input file
• An XOR function/method that takes as input two binary strings and returns the XOR result.
• A function/method for CRC calculation
• A function/method for CRC verification
Input file format:
Create YOUR OWN VALID input file.
Valid input files would be text files which contain only hexadecimal characters. Either upper or lower case letters may appear, but they would only be letters which correspond to hexadecimal characters. There would be no whitespace, punctuation, or special characters in the input files.
You should check for input correctness by implementing code to verify that each character in the input file is a valid hexadecimal character (0,1,2,3,4,5,6,7,8,9A,B,C,D,E,F,a,b,c,d,e,f). Valid upper and lower case hex letters will be given the same meaning (“a” = “A” = 1010, etc.)
If an input file contains any invalid characters (other than an end-¬?of-¬?file marker), then the program should issue an appropriate brief error message and terminate gracefully.
Print out the hexadecimal file that is read, 80 hex characters to a line.
Next, you should convert the hexadecimal file into binary. Recall that one hex character is four bits. Read the input file and form a binary string. The length of the binary string will be four times the length of the input file because each hexadecimal character will be replaced by 4 binary bits. You will have to define a separate function to get the binary equivalent of a hexadecimal character.
You must state how many zeroes are appended to the input. You must then print the binary version of the input file (after appending) 64 binary bits per line. You must also insert a space after every four binary bits that you print (increasing the line length to 80 characters).
Next, you will show the result of each XOR operation involved in the CRC calculation or verification. The result value at each step is a binary value that contains all of the digits of the dividend after an XOR operation.