CRC-16 / CRC-32 Calculator

CRC-32 and the common CRC-16 variants of text or hex bytes — computed in your browser.

Runs in your browser — nothing is uploaded

 

What a CRC is

A cyclic redundancy check is a short checksum computed from a block of data so that a receiver can tell whether the data arrived intact. Ethernet frames, ZIP and gzip archives, PNG chunks, SATA, Bluetooth, Modbus and countless serial protocols attach one. The sender computes the CRC and sends it with the data; the receiver recomputes it and compares.

CRCs are popular because they are cheap — a few gates in hardware or a table lookup per byte in software — and because they are very good at catching the errors real links make. A CRC of width n detects every single-bit error, every burst of errors no longer than n bits, and all but about 1 in 2ⁿ of every other kind of corruption.

How the calculation works

Treat the message as one long binary number and divide it by a fixed generator polynomial, using arithmetic where addition and subtraction are both XOR, with no carries. The remainder of that division is the CRC. For CRC-32 the generator is 0x04C11DB7 with an implied 33rd bit; CRC-16 variants use 16-bit generators such as 0x8005 or 0x1021.

In software the division is a shift register. For each bit of input the register shifts one place, and whenever a 1 falls off the top, the polynomial is XORed in. Because the result of feeding in any one byte depends only on that byte and the register's top byte, implementations precompute a 256-entry table and process a whole byte with one lookup, one shift and one XOR. That is what this tool does.

Four more parameters complete the definition: the register's initial value (0, or all ones so that leading zero bytes are not invisible), whether each input byte is fed in least-significant bit first ('reflected', matching how UARTs and Ethernet send bits), whether the final register is reflected, and a value XORed into the result. The CRC catalogue writes these as width, poly, init, refin, refout and xorout, plus a check value: the CRC of the nine ASCII characters 123456789.

The variants offered here

CRC-32 (also called CRC-32/ISO-HDLC): poly 0x04C11DB7, init 0xFFFFFFFF, reflected, xorout 0xFFFFFFFF, check 0xCBF43926. Used by zlib, gzip, ZIP, PNG and Ethernet.

CRC-16/ARC: poly 0x8005, init 0, reflected, check 0xBB3D — what most libraries call plain CRC-16. CRC-16/MODBUS is the same with init 0xFFFF, check 0x4B37, used in Modbus RTU frames.

CRC-16/CCITT-FALSE (CRC-16/IBM-3740): poly 0x1021, init 0xFFFF, not reflected, check 0x29B1 — often what a datasheet means by 'CRC-CCITT'. CRC-16/XMODEM is the same with init 0, check 0x31C3, used by XMODEM and many embedded bootloaders.

What a CRC cannot do

A CRC is an error-detecting code, not a cryptographic hash. It is linear, so the CRC of tampered data can be predicted and corrected, and collisions are trivial to construct. Use a CRC to catch accidents on a wire or disk; use SHA-256 to fingerprint content, and an HMAC or a signature to prove who sent it.

Examples

CRC-32 check value

Input

123456789

Output

Hex: 0xCBF43926
Decimal: 3421780262
CRC-16/MODBUS check value

Input

123456789

Output

Hex: 0x4B37
Decimal: 19255
CRC-16/MODBUS of a Modbus RTU request (hex bytes)

Input

01 03 00 00 00 0A

Output

Hex: 0xCDC5
Decimal: 52677
CRC-32 of a sentence

Input

The quick brown fox jumps over the lazy dog

Output

Hex: 0x414FA339
Decimal: 1095738169

How to use

  1. Choose CRC-32 or a CRC-16 variant.
  2. Pick Text, or Hex bytes for a raw frame like 01 03 00 00 00 0A.
  3. Paste your input and copy the hex or decimal checksum.

FAQ

Why are there several CRC-16s?

A CRC is defined by more than its width: the polynomial, the starting register value, whether bits are processed least-significant first, and a final XOR all change the result. Different protocols picked different combinations, so 'CRC-16' alone is ambiguous. Pick the variant your protocol's documentation names, or compare the check value for 123456789.

Is a CRC a secure hash?

No. A CRC is designed to catch accidental corruption such as flipped bits and line noise. It is linear, so anyone can change data and fix up the CRC to match. To detect deliberate tampering use SHA-256, or an HMAC when a key is shared.

Why doesn't my result match another tool?

Usually a different variant, a trailing newline, or bytes versus text. In Text mode this tool checksums the UTF-8 bytes of exactly what you typed; to checksum a binary frame, switch to Hex bytes so 0A means one byte, not the two characters 0 and A. CRC-32 here matches zlib.crc32 in Python, crc32 in PHP and the CRC stored in ZIP and PNG files.

Which byte order is the result in?

The value is shown as a number, most significant digit first. Protocols differ in how they send it: Modbus RTU, for example, transmits the low byte first, so a CRC of 0x4B37 goes on the wire as 37 4B.

Related tools