I am trying to implement the algorithm of a CRC check, which basically created a value, based on an input message.
So, consider I have a hex message 3F214365876616AB15387D5D59, and I want to obtain the CRC24Q value of the message.
The algorithm that I found to do this is the following:

typedef     unsigned long crc24;
    crc24 crc_check(unsigned char *input) {
        	unsigned char *octets; 
        	crc24 crc = 0xb704ce; // CRC24_INIT;
        	int i;
        	int len = strlen(input); 
    	octets = input;
    	while (len--) {
    		crc ^= ((*octets++) << 16); 
    		for (i = 0; i < 8; i++) {
    			crc <<= 1; 
    			if (crc & 0x1000000) 
    				crc ^= CRC24_POLY;
    	return crc & 0xFFFFFF;

where *input=3F214365876616AB15387D5D59.
The problem is that ((*octets++) << 16) will shift by 16 bits the ascii value of the hex character and not the character itself.
So, I made a function to convert the hex numbers to characters.
I know the implementation looks weird, and I wouldn't be surprised if it were wrong.
This is the convert function:

char* convert(unsigned char* message) {
    	unsigned char* input;
    	input = message;
    	int p;
    	char *xxxx[20];
    	for (p = 0; p < length(message) - 1; p = p + 2) {
    		char* pp[20];
    		pp[0] = input[0];
    		char *c[20];
    		c[0]= input[0];
    		char cc;
    		char tt[2];
    		cc = (char ) strtol(pp, &pp, 16);
    	return xxxx;


unsigned char *msg_hex="3F214365876616AB15387D5D59";
    crc_sum = crc_check(convert((msg_hex)));
    printf("CRC-sum: %x\n", crc_sum);

Thank you very much for any suggestions.

While I know you're new with this site, it should be mentioned that Cross-posting is frowned upon as it can cause a duplication of effort on the part of the two communities. It's generally considered best not to cross-post at all, but if you feel you would get better results this way (and not annoy people to the point that they ignore you), please at least mention that you've posted the same question elsewhere so the groups can review what was said elsewhere.

This article has been dead for over six months. Start a new discussion instead.