C program of Cyclic Redundancy Check
C program of Cyclic Redundancy Check Program #include <stdio.h> // shorthand for loops #define forn(i,e) for(int i = 0; i < e; i++) #define forsn(i,s,e) for(int i = s; i < e; i++) int validate_data( int len_data, int data[], int len_divisor, int divisor[]){ // Returns 1, if the data is correct // Returns 0, if the data is incorrect/corrupted. int current_bits[len_divisor]; forn(i, len_divisor) { current_bits[i] = data[i]; } // the logic is same as generating the crc. forn(i, len_data) { if (!current_bits[ 0 ]) { forn(j, len_divisor- 1 ) { current_bits[j] = current_bits[j+ 1 ]; } current_bits[len_divisor- 1 ] = data[i+len_divisor]; } else { forn(j, len_divisor) { current_bits[j] = current_bits[j]^divisor[j]; } forn(j, len_divisor- 1 ) { current_bits[j] = current_bits[j+ 1 ]; } current_bits[len_divisor- 1 ]