Compute the CRC (cyclic redundancy check) used to detect corrupted data in communication, files and memory. Pick a common variant from the presets, or set the width, generator polynomial, initial value, reflection and final XOR to match a specification. For short inputs, the tool shows the polynomial division that a CRC really is, one step at a time.
Favorites and recently used calculators are stored only in this browser (localStorage).
Result
CRC (hex)
–
CRC (binary)
–
CRC (decimal)
–
Data length
–
Check value (CRC of "123456789")
–
Generator polynomial
–
Polynomial division, step by step
The tool computes bit by bit, the straightforward way, which gives the same result as fast table-driven implementations. Use the check value to compare your parameters with a specification or library.
See it as a graph
Other inputs stay at their current values while the chosen input varies from 1/4 to 4 times its current value. The red dot is the current value.
What a CRC is: the remainder of a polynomial division
A CRC (cyclic redundancy check) treats the bits of the data as the coefficients of a polynomial over modulo-2 arithmetic, divides it by a generator polynomial and uses the remainder as the check value. In modulo-2 arithmetic both addition and subtraction are XOR, so the division is just "if the leading bit is 1, XOR the generator and shift by one" repeated. For a w-bit CRC, w zeros are appended to the data before dividing, and the w-bit remainder is sent after the data. If the receiver repeats the calculation and gets the same remainder, it concludes that the data arrived intact. Choose CRC-8 and enter the data "A" to watch 0100 0001 followed by eight zeros being divided by x⁸ + x² + x + 1 (0x07).
Initial value, reflection and final XOR
Standard CRCs are not just the bare remainder; each is defined with a few extra conventions. The initial value starts the register at something other than 0 (often all ones) so that leading zero bytes still change the result. Input reflection matches serial links such as UART and Ethernet that send each byte least significant bit first, and it is used together with output reflection. The final XOR inverts the result or applies another mask. For example, CRC-32 is defined with the polynomial 0x04C11DB7, initial value 0xFFFFFFFF, reflected input and output and a final XOR with 0xFFFFFFFF, and the CRC of "123456789" is 0xCBF43926. With the same polynomial 0x1021, CRC-16/CCITT-FALSE (0x29B1), XMODEM (0x31C3) and KERMIT (0x2189) give different results because their conventions differ.
Which errors a CRC catches
With a well-chosen generator polynomial, a CRC reliably detects many kinds of errors. A w-bit CRC detects every burst error of length w or less. If the generator has x + 1 as a factor, it detects every error with an odd number of flipped bits, and a suitable polynomial also detects every two-bit error up to a certain data length. The chance of missing other, random errors is roughly 2⁻ʷ, about 1 in 4.3 billion for CRC-32. A CRC only detects errors, though; it cannot tell which bit is wrong, so memories that need correction use an ECC such as a Hamming code.
Where CRCs are used
CRCs are everywhere: the FCS at the end of an Ethernet frame (CRC-32), PCI Express packets, USB, CAN, SD card and storage commands, file formats such as ZIP and PNG, and industrial protocols such as Modbus (CRC-16/MODBUS). In hardware, a CRC can be computed one bit at a time with a linear feedback shift register (LFSR) built from flip-flops and XOR gates; in software, a 256-entry table speeds it up to a byte at a time. CRC-32C (Castagnoli), used in iSCSI and storage, can be computed with dedicated instructions on some x86 and Arm CPUs.
Checking that your CRC matches the spec
When a CRC does not match, one of the parameters almost always differs from the specification. First compare the check value for "123456789" from the spec or library with the one shown here. If they differ, suspect the initial value, the reflection settings, the final XOR and the way the polynomial is written (with the top x^w term omitted, or bit-reversed) in turn. Next, confirm which bytes the CRC covers (for example, whether the header is included) and the byte order on the wire (whether the high or low byte of a CRC-16 is sent first). Entering the actual bytes from a capture as hex here makes the problem easier to isolate.
AIt does nothing and passes the data on until software notices
BIt powers off the device when an error is found
CIt adds a CRC to detect errors and, on error, signals that the packet was not received so it is resent
Show answer and explanation
Answer: C. It adds a CRC to detect errors and, on error, signals that the packet was not received so it is resent
The data link layer sends each packet with a sequence number and a CRC (cyclic redundancy check) code. The receiver checks the CRC and returns ACK if it is good or NAK if it is not; the sender keeps each packet until it is acknowledged and resends it on NAK. Thanks to this, even when the physical layer occasionally flips a bit, the upper layers and software receive correct data.
AGenerating pseudo-random patterns, such as test patterns, and computing CRCs
BMeasuring precise time
CAmplifying analog signals
Show answer and explanation
Answer: A. Generating pseudo-random patterns, such as test patterns, and computing CRCs
With properly chosen taps, an n-bit LFSR cycles through all 2ⁿ − 1 nonzero states, producing a seemingly random maximal-length sequence (m-sequence). Built only from XORs and flip-flops, it is used for built-in self-test (BIST) pattern generation and response compaction, CRC calculation in protocols such as Ethernet, and scramblers that randomize data to reduce electromagnetic noise. Its output is predictable, so it is unsuitable for cryptographic randomness.
FAQ
Why are there so many kinds of CRC-16?
The name CRC-16 only says the CRC is 16 bits wide; the polynomial, initial value, reflection and final XOR differ from one standard to another. Modbus, for example, uses CRC-16/MODBUS (0x8005, initial value 0xFFFF, reflected), while XMODEM uses 0x1021 with initial value 0 and no reflection. Check which parameters your standard uses and match them with a preset or the custom settings.
What is the "123456789" check value?
It is the CRC of the nine ASCII bytes "123456789", a fixed value for each CRC variant. CRC catalogs and library documentation list it as a reference for confirming that a set of parameters is right. It is 0xCBF43926 for CRC-32 and 0x4B37 for CRC-16/MODBUS.
How is a CRC different from a checksum?
A checksum uses a simple operation such as adding the bytes, so it easily misses reordered data or errors that cancel out. A CRC is based on polynomial division, so it distinguishes bit positions and reliably catches burst errors and more. That is why CRCs are the usual choice for error detection in communication and storage.
Can a CRC correct errors?
In general, no. A CRC detects whether an error occurred but not which bit is wrong, so systems recover by retransmitting. Where retransmission is impossible, as in memory, error-correcting codes (ECC) such as Hamming, BCH or LDPC codes are used.
How do I enter hex bytes?
Enter two digits per byte, such as "31 32 33", "313233" or "0x31,0x32,0x33". Spaces, commas, colons, hyphens and "0x" are ignored. With Text selected, the characters are converted to UTF-8 bytes before the calculation.