Dataescher CRC Calculator

A cyclic redundancy check is a shift register fed one bit of your data at a time, and the whole family of them is described by five numbers: the width, the polynomial, the initial value loaded into the register, whether the algorithm is reflected, and a final XOR. Set those five and this page computes the CRC of whatever you type, shows you the algorithm running one step at a time, and writes the code to do it in C, C#, VB.NET or Delphi.

Everything runs in your browser. Nothing you type is uploaded, logged or sent anywhere.

Algorithm

0x
0x
0x

Result

Decimal
Binary
Big endian bytes
Little endian bytes
Check value ("123456789")

Input data

Working constants

A reflected algorithm feeds the register from the other end, so an implementation reverses the polynomial and the seed once up front rather than reversing every byte. These are the numbers the generated code actually contains.

Register polynomial
Register seed
First table entries

Walk through the algorithm

Input
Register
This step
The C code being executed

						

Generated code

Written for the parameters above rather than as a configurable routine, so the constants are folded in, only the branch you need survives, and a final XOR of zero disappears entirely. Each snippet comes with a resumable form that takes a CRC returned earlier and carries on from it, so a stream too large to hold in memory can be checksummed a piece at a time and still land on the same value.


			

How a CRC works

Treat the message as one enormous binary number and divide it, using carry-free binary arithmetic, by a constant called the generator polynomial. The remainder is the CRC. Because there are no carries, that division is nothing more than a shift register and a conditional XOR, which is why a CRC costs so little in hardware and why the same handful of parameters describes every variant in use.

  1. Seed the register. Load the initial value. A seed of all ones rather than all zeros is what stops leading zero bytes in the message from being invisible to the checksum.
  2. Feed in each byte. XOR it into the end of the register the algorithm reads from: the top byte for a normal algorithm, the bottom byte for a reflected one.
  3. Shift eight times. Each shift drops one bit off the end. When that bit is a one, XOR the polynomial back in. That single conditional is the entire division.
  4. XOR the result. Apply the final XOR and you have the CRC.

The lookup table is a shortcut, not a different algorithm. The eight shifts for a given byte depend only on that byte and on the eight register bits it meets, so all 256 possible outcomes can be worked out once and stored. Both forms are generated above and they always agree.

Reflection exists because serial hardware transmits the least significant bit first. Rather than reverse every byte on the way in and reverse the result on the way out, an implementation reverses the polynomial and the seed once and runs the register backwards. The Working constants panel shows both numbers, which is why the seed printed in the generated code for an algorithm like CRC-16/RIELLO is 0x554D even though the published initial value is 0xB2AA.

The check value is the agreed fingerprint of an algorithm: the CRC of the nine ASCII characters 123456789. Every preset here is verified against its published check value, so if your own code reproduces the number shown in the Result panel, your implementation is right.

Linking to a calculation

Every control can be set from the query string, so a particular calculation can be bookmarked, shared or linked from a datasheet or bug report. The address bar keeps itself up to date as you work, and Copy link puts the current link on the clipboard.

/apps/crc-calculator/?width=32&poly=0xA833982B&init=0xFFFFFFFF&reflect=true&xor=0xFFFFFFFF&data=0132356E

A parameter that cannot be read is ignored and flagged rather than quietly changing the answer, so a mistyped link is easy to spot. Add ?selftest=1 to run every preset against its published check value and see the results.