Developer and Text Tools

CRCs and Hamming Codes: How Computers Catch and Fix Bit Errors

How CRC checksums detect corrupted data, why there are so many CRC-16 and CRC-32 variants, and how Hamming codes locate and correct a flipped bit.

Saizul Amin
Saizul Amin30 Oct 2026 · 3 min read
CRCs and Hamming Codes: How Computers Catch and Fix Bit Errors

CRCs and Hamming Codes: How Computers Catch and Fix Bit Errors

Every time data moves or sits in storage, a few bits can flip. Electrical noise on a cable, interference on a radio link, a cosmic ray hitting memory or a worn storage cell can all corrupt data silently. Two families of codes protect against this: checksums such as CRCs that detect errors, and error-correcting codes such as Hamming codes that can also fix them. The free CRC and Hamming Code Calculator lets you compute and experiment with both.

Cyclic redundancy checks

A CRC treats a message as a long binary polynomial and divides it by a fixed generator polynomial. The remainder, 8, 16, 32 or 64 bits long, is appended to the message. The receiver repeats the division; if its remainder differs, the data was corrupted.

CRCs are excellent at catching the errors that really happen. An n-bit CRC catches every burst of errors up to n bits long, every single-bit and double-bit error in reasonably sized messages, and lets a random corruption slip through with a probability of only about 1 in 2 to the power n: one in 4.3 billion for CRC-32.

Why there are so many variants

A CRC is defined by more than its width and polynomial. Implementations also choose an initial register value, whether each byte is processed with its bits reflected, whether the final value is reflected, and a value to XOR at the end. CRC-16/MODBUS and CRC-16/ARC use the same polynomial but different initial values, so they give different results for the same data.

The standard way to identify a variant is its check value: the CRC of the ASCII text 123456789. CRC-32, used by Ethernet, ZIP and PNG, gives 0xCBF43926; CRC-16/MODBUS gives 0x4B37. The calculator shows fourteen common variants side by side and verifies each against its published check value, so when a device's checksum does not match, you can quickly find the variant it uses.

Hamming codes

Detecting an error is often enough, because the data can be sent again. Sometimes it cannot: memory chips, deep-space probes and storage need to fix errors on the spot. Richard Hamming invented his codes at Bell Labs in 1950 after his weekend computer jobs kept failing on single-bit errors.

Parity bits sit at positions 1, 2, 4, 8 and so on. Each covers the positions whose binary number includes that bit. When a word arrives, the receiver recomputes the parities; the pattern of failures, called the syndrome, is the binary number of the position that flipped. Flip it back, and the error is corrected. Four data bits need three parity bits, giving the classic Hamming(7,4) code.

Adding one overall parity bit gives SECDED: single error correction, double error detection. ECC memory in servers works this way, fixing single-bit errors and alerting on double ones.

Detection is not security

CRCs and Hamming codes protect against accidents. Anyone who changes data on purpose can recompute the CRC. To detect tampering, use a cryptographic hash or message authentication code.

Matching a device

If a device's documentation gives only a polynomial, compute the CRC of a known message and compare it with each variant's value in the table until one matches.

Step by step

  1. Choose CRC, Hamming encode or Hamming decode.
  2. For CRCs, enter text or hex data.
  3. Compare the values and parameters for all fourteen algorithms.
  4. For Hamming, enter data bits to get a codeword.
  5. Flip a bit and decode it to watch the correction.

Privacy

Calculations run in your browser.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages