Algorithms

CRC-32

The error-detection checksum in every ZIP and PNG and gzip, and unreflected in bzip2. Four bytes and useless against an attacker
IDcrc3232 / 46CRC · 32-bit
Hash / Non-cryptographic

CRC-32

The checksum in every ZIP, PNG, gzip and bzip2.

Digest
32-bit · 4 bytes
HMAC
no key mode
Security
NOT for security: error-detection checksum only
Family
4 in CRC
4 options, 0 required

Sample

hex
0d4a1185
base64
DUoRhQ==

Options

encodingstring
default hex
Output encoding: hex, base64, base64url, binary
variantstring
default iso-hdlc
Which CRC-32: iso-hdlc as zlib, gzip, ZIP and PNG compute it, or bzip2
roundsnumber
default 1
How many times to hash, each round hashing the previous digest
chainstring
default bytes
What each round after the first hashes: bytes of the digest, or its lowercase hex

Access

Createcreate("crc32")
CLIhashes crc32 'hello world'
Tryplayground with the sample above
Kincrc64, crc24, crc16-xmodem

The IEEE CRC-32, the one in ZIP, PNG, gzip and Ethernet. It catches accidental bit flips and nothing else. Anyone can forge a CRC-32 in microseconds, since it's linear.

ts
create("crc32").hash("123456789").digest; // "cbf43926", the standard check value
create("crc32").hash("The quick brown fox jumps over the lazy dog").digest; // "414fa339"
create("crc32").hash("123456789", { variant: "bzip2" }).digest; // "fc891918"

The avalanche panel on the landing makes the linearity visible. Flip one input bit and the CRC changes by a pattern that depends only on where that bit sat, not on the rest of the input. A real hash moves a random half. Printed big-endian, as crc32 tools write it.

Variants

variant picks which CRC-32. The names come from the CRC catalogue.

variantWho uses it
iso-hdlc (default)zlib, gzip, ZIP, PNG, Ethernet
bzip2bzip2, after every block and once more for the stream

Same polynomial, same all-ones start and finish. bzip2 just reads the bits the other way round, so the answer is different. A checksum from a .bz2 file that matches neither is usually the stream CRC, which rotates the running value left by one bit before each block's CRC goes in. One block and the two agree.