This repository contains an example implementation of the CRC (Cyclic Redundancy Check) algorithm in C. It consists of two files:
crc.c
— contains a universal CRC calculation function that supports customizable width, polynomial, initial value, XOR output, and input/output reflection flags;main.c
— demonstrates how to use thecrc_compute
function fromcrc.c
using the test string"123456789"
.
Parameters for most well-known CRC algorithms — including polynomial, init
, xorOut
, refIn
, and refOut
— can be found at:
Example parameters in this repository: CRC-32/ISO-HDLC
Expected CRC result for the string "123456789"
: 0xCBF43926
gcc -o crc_test main.c crc.c
./crc_test
- Requires a precomputed CRC table.
- Supports CRC sizes up to 32 bits.
- Does not support differing refIn and refOut flags (only cases where both are either true or false).