How CRC-32 Is Calculated: Checksums, Polynomial and Adler-32
Last updated: · 5 min read
CRC-32 turns a block of data into a 32-bit checksum that catches accidental corruption during transfer or storage. The same CRC-32 appears in Ethernet frames, ZIP archives, PNG images and gzip files. It is very fast to compute, but it is not a cryptographic hash and offers no protection against deliberate changes. This guide explains the polynomial, the steps of the calculation, how it differs from the Adler-32 checksum used by zlib, and why the CRC of a file and the CRC of pasted text may not agree. The values in the example are real output from the CRC-32 Checksum Calculator.
Formula
CRC-32 (ISO 3309 / ITU-T V.42; Ethernet, ZIP, PNG, gzip): polynomial = 0x04C11DB7 (0xEDB88320 in bit-reversed form) initial = 0xFFFFFFFF per byte = crc ← table[(crc ⊕ byte) & 0xFF] ⊕ (crc >>> 8) final step = crc ⊕ 0xFFFFFFFF Adler-32 (RFC 1950, zlib): s1 = 1 + sum of all bytes (mod 65521) s2 = sum of s1 after each byte (mod 65521) Adler-32 = s2 × 65536 + s1
A CRC treats the data as one very long binary number and takes the remainder of dividing it by a fixed polynomial in modulo-2 arithmetic. Real implementations avoid bit-by-bit division with a 256-entry table: each byte is XORed with the low byte of the register and selects a table value. Starting from 0xFFFFFFFF and inverting at the end makes leading zero bytes affect the result. Adler-32 simply keeps two running sums; 65521 is the largest prime below 65536. The tool converts the text to UTF-8 bytes first and calculates both values over those bytes.
What the inputs mean
- Text
- The text to checksum. Spaces and line breaks are not trimmed. The text is encoded as UTF-8, so non-ASCII characters take more than one byte (é is two bytes); the Size line in the output shows the byte count.
Worked example: CRC-32 and Adler-32 of "123456789"
- Input: 123456789. This string is the standard check input used to validate CRC implementations; in UTF-8 it is nine bytes (31 32 … 39).
- The register starts at 0xFFFFFFFF. Each of the nine bytes selects a table entry and updates the register; a final XOR with 0xFFFFFFFF gives cbf43926, the well-known check value for CRC-32.
- The same number in decimal is 3421780262. Some tools and databases show a CRC as an unsigned decimal integer.
- Adler-32: s1 = 1 + (49 + 50 + … + 57) = 478 = 0x01de. s2 adds up s1 after every byte: 50 + 100 + 151 + 203 + 256 + 310 + 365 + 421 + 478 = 2334 = 0x091e. Together that is 091e01de.
- Output of the tool: CRC-32 (hex): cbf43926, CRC-32 (decimal): 3421780262, Adler-32 (hex): 091e01de, Size: 9 bytes.
- Change the last digit (123456788) and the CRC-32 becomes bcf309b0: all eight hex digits change. The Adler-32 becomes 091d01dd; on short inputs each half merely drops by one.
- A longer input: for The quick brown fox jumps over the lazy dog the tool shows CRC-32 (hex): 414fa339 and Size: 43 bytes.
Result: CRC-32("123456789") = cbf43926 (decimal 3421780262), Adler-32 = 091e01de, 9 bytes.
How to read the result
CRC-32 detects every single burst error up to 32 bits long, and a random corruption slips through with a probability of roughly one in 4.3 billion. That is why archive formats and network protocols rely on it. The calculation is linear and uses no key, however: someone who changes the data on purpose can append a few bytes so that the CRC stays the same, or simply recompute the CRC and replace it. To check that a download is authentic you need SHA-256, and to check where it came from you need an HMAC or a digital signature. Adler-32 is quicker to compute but weak on short inputs; the zlib format uses it, while gzip and PNG use CRC-32.
Common mistakes
- Using CRC-32 for security. It is unsuitable for password hashing, licence checks or tamper protection, because data with any desired CRC is easy to construct.
- Comparing the CRC of a file with the CRC of pasted text. Line-ending style (CRLF or LF), a final newline and a leading byte order mark all change the result, as does the newline that echo appends.
- Mixing CRC-32 variants. iSCSI and several file systems use CRC-32C (Castagnoli), which has a different polynomial and gives a different value for the same data.
- Overlooking byte order. gzip stores the CRC least significant byte first and PNG most significant byte first, so four bytes read out of a file may appear reversed.
- Dropping leading zeros. The result is always eight hex digits; writing 0e048d3e as e048d3e breaks a string comparison.
- Ignoring the text encoding. The tool uses UTF-8; the same text saved as Windows-1252 or UTF-16 consists of different bytes and therefore has a different CRC.
Frequently asked questions
What is the difference between CRC-32 and SHA-256?
CRC-32 is a 32-bit checksum designed to catch accidental errors; it is fast, but producing different data with the same value is easy. SHA-256 is a 256-bit cryptographic hash, and finding a second input with the same digest is not feasible in practice.
Can two different inputs have the same CRC-32?
Yes. There are only about 4.3 billion possible values, and among roughly 77,000 random inputs the chance of at least one collision reaches 50 percent. CRC-32 should not be used as a unique identifier or a secure fingerprint.
When is Adler-32 used?
The zlib compressed data format (RFC 1950) uses Adler-32 for integrity because it is faster than CRC-32. For inputs shorter than a few hundred bytes the sums never wrap around 65521, which makes its error detection weak.
Why doesn't my result match the CRC shown by ZIP or 7-Zip?
Archive tools work on the raw bytes of the file. Copying and pasting text can change line endings, drop or add a trailing newline or alter the encoding. Comparing the byte count in the Size line with the file size reveals the difference quickly.
Are 0xEDB88320 and 0x04C11DB7 the same polynomial?
Yes, written in opposite bit order. Software implementations process each byte starting from its least significant bit and therefore use the reversed constant 0xEDB88320.
Is my text sent to a server?
No. The checksum is calculated by JavaScript on the page, in your browser.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.