hashes · API

hashes.crc32

CRC-32 (IEEE 802.3 / zlib / gzip / PNG) — reflected polynomial 0xEDB88320, init/xorout 0xFFFFFFFF. Table-driven with a slice-by-8 fast path.

crc32(data, seed=0) reproduces zlib.crc32(data) in Python (and, by extension, gzip/PNG CRCs). Passing a previous result as seed chains across buffers exactly like zlib's crc32(buf, crc): crc32(b, seed=crc32(a)) == crc32(a + b).

Structs

Crc32

struct Crc32

Incremental CRC-32. seed is the previous crc32 result (0 to start).

Implements Copyable, Movable

__init__

def __init__(out self, seed: UInt32 = UInt32(0))

update

def update(mut self, data: Span[UInt8])

finish

def finish(self) -> UInt32

Functions

crc32

def crc32(data: Span[UInt8], seed: UInt32 = UInt32(0)) -> UInt32