Skip to main content

Module checksum

Module checksum 

Source
Expand description

The two checksums the compressed formats carry.

gzip (RFC 1952 §2.3.1) ends a member with a CRC-32 of the uncompressed data; zlib (RFC 1950 §2.2) ends its stream with an Adler-32. Neither is a cryptographic hash — they exist to catch a truncated or corrupted stream before a caller trusts the bytes that came out of the inflater — so the “no cryptography from scratch” exception does not apply and both are written here.

Both come in an incremental form (Crc32::new().update(..).finish()) for callers that see the data in pieces, and a one-shot function for the common case.

Structs§

Adler32
An incremental Adler-32.
Crc32
An incremental CRC-32.

Functions§

adler32
Adler-32, the zlib trailer checksum. adler32(b"Wikipedia") is 0x11E60398.
crc32
The CRC-32 gzip uses (IEEE 802.3, reflected, initial value and final XOR both all-ones). crc32(b"123456789") is 0xCBF43926, the check value every CRC catalogue lists for this variant.