Crate crc32c

Source
Expand description

This crate provides the CRC-32-Castagnoli algorithm.

It provides both a software implementation, and a hardware-optimized one for SSE 4.2.

§Example

let message = b"Hello world!";

let crc = crc32c::crc32c(message);

assert_eq!(crc, 0x7B_98_E7_51);

§Enabling hardware acceleration

If you compile your code with -C target-features=+sse4.2, then the hardware-optimized version will be compiled into the code.

Otherwise, the crate will use cpuid at runtime to detect the running CPU’s features, and enable the appropriate algorithm.

Structs§

Crc32cHasher
Implementor of Hasher for CRC-32C.
Crc32cReader
Reader wrapper which tracks the checksum of all bytes read.
Crc32cWriter
Writer wrapper which tracks the checksum of all bytes written.

Functions§

crc32c
Computes the CRC for the data payload.
crc32c_append
Computes the CRC for the data payload, starting with a previous CRC value.
crc32c_combine
Computes the “combined” value of two CRC32c values. Specifically, given two byte streams A and B and their CRC32c check values crc32c(A) and crc32c(B), this function calculates crc32c(AB) using only crc32c(A), crc32c(B), and the length of B.