Skip to content

CRC Calculator

Compute CRC-8, CRC-16 and CRC-32 checksums with full control over the polynomial, seed, reflection and final XOR.

Input is

9 bytes of input

The CRC-32 in zip, gzip, PNG and Ethernet FCS. The default nearly everywhere.

Result

Hex0xCBF43926
Decimal3421780262
Bytes (big-endian)CB F4 39 26
Bytes (little-endian, e.g. Modbus wire order)26 39 F4 CB
Binary (32-bit)11001011 11110100 00111001 00100110
Width
32
Poly
0x04C11DB7
Init
0xFFFFFFFF
RefIn
true
RefOut
true
XorOut
0xFFFFFFFF

Check value: this model returns 0xCBF43926 for the string “123456789”, against a published 0xCBF43926 — match.

Model catalogue

Every model below is verified against its published check value in this site's test suite. Where two rows share a polynomial, the difference is the seed, the reflection or the final XOR - which is exactly why two libraries can both claim “CRC-16” and disagree.

NameWPolyInitRefXorOutCheck
CRC-8/SMBUS, ATM HEC80700-/-00F4
CRC-8/MAXIM-DOW, Dallas 1-Wire83100in/out00A1
-89BFF-/-00DA
CRC-16/IBM-3740, CRC-16/AUTOSAR161021FFFF-/-000029B1
-168005FFFFin/out00004B37
CRC-16, CRC-16/LHA, ARC1680050000in/out0000BB3D
CRC-16/ACORN, ZMODEM1610210000-/-000031C3
CRC-16/CCITT, CRC-CCITT (true)1610210000in/out00002189
-168005FFFFin/outFFFFB4C8
CRC-32/ISO-HDLC, PKZIP, Ethernet, gzip, PNG3204C11DB7FFFFFFFFin/outFFFFFFFFCBF43926
CRC-32/ISCSI, Castagnoli321EDC6F41FFFFFFFFin/outFFFFFFFFE3069283
CRC-32/AAL5, CRC-32/DECT-B3204C11DB7FFFFFFFF-/-FFFFFFFFFC891918
-3204C11DB7FFFFFFFF-/-000000000376E6E7

How a CRC works

A CRC treats the message as the coefficients of a polynomial over GF(2) - the field with two elements, where addition and subtraction are both XOR. Divide that polynomial by a fixed generator and the remainder is the CRC. In hardware it is a shift register with XOR taps at the positions of the generator's set bits, which is why it costs almost nothing to compute inline with a serial stream.

The generator is what determines the error-detection strength. A well-chosen degree-32 polynomial catches every single-bit error, every double-bit error over practical frame lengths, every odd number of bit errors, and every burst of 32 bits or fewer. That last property is the point: real-world corruption on a wire or a flash cell tends to arrive in bursts, not as scattered independent flips.

The other five parameters are bookkeeping, but they are not optional. A non-zero seed means a run of leading zero bytes changes the result, so a truncated frame does not silently pass. Reflection matches the LSB-first order that serial hardware shifts bits in. The final XOR means an all-zero message does not produce an all-zero CRC. Get any one of them wrong and your value disagrees with everyone else's.

CRC is not a hash

A CRC is linear: CRC(a XOR b) is a simple function of CRC(a) and CRC(b). That makes it trivial to modify a message and patch its CRC back to the original value, so a CRC proves nothing about intent. It detects accidents, not adversaries. If the threat model includes someone deliberately editing the data, you want SHA-256 or an HMAC, not a checksum - reach for the hash generator instead.

The flip side is that a CRC is far cheaper. CRC-32C runs as a single x86 instruction, so filesystems and network stacks can checksum every block and every frame without a measurable cost.

Code Examples

import zlib

data = b"123456789"

print(hex(zlib.crc32(data)))  # 0xcbf43926 - CRC-32/ISO-HDLC

# Generic bit-by-bit model
def crc(data, width, poly, init, refin, refout, xorout):
    mask = (1 << width) - 1
    top = 1 << (width - 1)
    reg = init & mask
    for byte in data:
        if refin:
            byte = int(f"{byte:08b}"[::-1], 2)
        reg ^= byte << (width - 8)
        for _ in range(8):
            reg = ((reg << 1) ^ poly) & mask if reg & top else (reg << 1) & mask
    if refout:
        reg = int(f"{reg:0{width}b}"[::-1], 2)
    return (reg ^ xorout) & mask

print(hex(crc(data, 16, 0x8005, 0xFFFF, True, True, 0x0000)))  # 0x4b37 MODBUS

Frequently Asked Questions

What is a CRC?

A cyclic redundancy check treats your message as a polynomial over GF(2) and returns the remainder after dividing by a fixed generator polynomial. Change any bit of the message and the remainder changes, which is what makes it a good error-detecting code for frames, files and flash images.

Why do two CRC-16 implementations give different answers?

Because 'CRC-16' names a polynomial, not an algorithm. A CRC is fully specified only by six parameters: width, polynomial, initial value, whether input bits are reflected, whether the output is reflected, and the final XOR. CRC-16/MODBUS and CRC-16/ARC share a polynomial and differ only in the seed, and they produce completely different values.

Which CRC-16 is 'CCITT'?

Both of them, unhelpfully. CRC-16/CCITT-FALSE uses polynomial 0x1021 with seed 0xFFFF and no reflection, and is what most libraries mean. CRC-16/KERMIT uses the same polynomial with seed 0x0000 and reflection on both sides, and is what the CCITT specification actually describes. Check the check value: 0x29B1 versus 0x2189 for the string 123456789.

What is the check value?

The CRC of the nine ASCII bytes '123456789'. Every published CRC catalogue lists it, so it is the fastest way to confirm that your implementation and someone else's agree. Each preset here is verified against its documented check value in the test suite.

What is the difference between CRC-32 and CRC-32C?

Different generator polynomials. CRC-32 uses 0x04C11DB7 and is the one in zip, gzip, PNG and Ethernet. CRC-32C uses Castagnoli's 0x1EDC6F41, has better error-detection properties for short messages, and is what iSCSI, ext4, Btrfs and the SSE4.2 crc32 instruction use.

What does 'reflected' mean?

Reflection reverses bit order. Reflect-in reverses the bits of each input byte before it enters the register; reflect-out reverses the whole register at the end. Reflected variants exist because bit-serial hardware shifts LSB-first, and they are not interchangeable with the non-reflected form - CRC-32 and CRC-32/BZIP2 share a polynomial and differ only in reflection.

Is a CRC a hash function?

It is a checksum, not a cryptographic hash. A CRC reliably detects accidental corruption - burst errors in particular - but it is linear, so anyone can craft a different message with the same CRC. Use SHA-256 when you need integrity against a deliberate attacker.

Why does my Modbus CRC look byte-swapped?

Modbus RTU transmits the CRC low byte first, unlike almost every other protocol. The calculator gives you both orders: the big-endian form is the numeric value, and the little-endian form is what goes on the wire in a Modbus frame.

Can I use a custom polynomial?

Yes. Pick Custom and set the width, polynomial, initial value, reflection flags and final XOR yourself. Polynomials are entered in normal (MSB-first) form with the implicit top bit omitted, which is the convention every catalogue uses.

Does the CRC cover the CRC itself?

In most protocols the CRC is computed over the payload and appended. Running the CRC over payload plus CRC yields a constant residue - zero for many models - which is how receivers check a frame in one pass rather than recomputing and comparing.

Related Tools

This tool runs entirely in your browser - nothing you enter is uploaded or stored.