🧾

CRC → C Code Generator

Generate a paste-ready table-driven CRC routine in C from a preset or custom polynomial.

Input
ℹ Pick a preset, or choose Custom and edit the parameters.
Generated C
Check ("123456789")—
—
💡 Usage & Formula

Emits a 256-entry lookup table and a crcN_compute() function. The Check value is the CRC of ASCII "123456789" — the standard self-test constant for verifying an implementation.

When you need it: Adding integrity checks to firmware or a serial protocol — generating a ready table-driven or bitwise CRC routine (CRC-8/16/32) that matches the polynomial the other end expects.

Worked example: CRC-16/CCITT uses poly 0x1021, init 0xFFFF; a 256-entry table costs 512 bytes of flash for roughly 8× the speed of the bit-at-a-time loop. As a sanity check, CRC-32 of the ASCII string "123456789" is 0xCBF43926.

Tips & gotchas:

  • Poly, init, reflect-in, reflect-out and xor-out must all match the other end exactly, or every check fails.
  • Table-driven for throughput; bitwise (or nibble-table) when flash is tight.
  • A CRC detects accidental errors — it is not a cryptographic hash and offers no tamper protection.
  • Always validate a new implementation against a published check value before trusting it in the field.
📖 References:CRC Catalogue (RevEng)