Write c code to calculate CRC using polynomial: x^32+x^30+x^28+x^23+x^18+x^17+x^16+x^15+x^8+x^7+x^6+x^3+x^2+1 for the message in which each character has been stored in an array of (unsigned char) messageBuffer[MESSAGE_LENGTH]. After calculate the CRC, store back the message with CRC appended to it into (unsigned char) messagewithcrcBuffer[MESSAGE_LENGTH+4].

I know how CRC works but I am unsure how I can get each character from the array and convert to number then concanate all the numbers(for complete message) to be moded by the polynomial to get crc. Can someone help me, please?

This is an example

#define MAX_ESTIMATED_LENGTH 300

Declare proper variables

char buffer[MAX_ESTIMATED_LENTG

int len, i;

unsigned long int crc;

Now you have to copy the message from somewhere to the buffer:

strcpy (buffer, somemessage);

len = strlen(buffer);

Now calculate the CRC (I assume you have your calculation function ready) using a for loop:

crc = 0;

for (i=0; i<len; i++) {

crc = CalcCRC32(buffer[i], crc); /* use previous crc in your calculus */

}