Skip to content

hash.crc32

Constants #

const ieee = u32(0xedb88320)

polynomials

const castagnoli = u32(0x82f63b78)
const koopman = u32(0xeb31d82e)
const q = u32(0x814141ab)

q is the standard CRC-32Q polynomial (MSB-first).

const q_reflected = u32(0xd5828281)

q_reflected is the reflected (LSB-first) form of CRC-32Q polynomial.

const crc32c = castagnoli

Named aliases for common CRC-32 variants.

const crc32k = koopman
const crc32q = q
const crc32q_reflected = q_reflected

fn new #

fn new(poly u32) &Crc32

new creates a Crc32 polynomial.

fn sum #

fn sum(b []u8) u32

sum calculates the CRC-32 checksum of b by using the IEEE polynomial.

fn sum_crc32c #

fn sum_crc32c(b []u8) u32

sum_crc32c calculates the CRC-32C checksum of b.

fn sum_crc32k #

fn sum_crc32k(b []u8) u32

sum_crc32k calculates the CRC-32K checksum of b.

fn sum_crc32q #

fn sum_crc32q(b []u8) u32

sum_crc32q calculates the CRC-32Q checksum of b.

fn sum_with_poly #

fn sum_with_poly(poly u32, b []u8) u32

sum_with_poly calculates the CRC-32 checksum of b for the provided polynomial. Built-in constants use their canonical parameter sets.

fn (Crc32) update_state #

fn (c &Crc32) update_state(state u32, b []u8) u32

update_state updates an internal CRC state with the bytes in b. Start from ~u32(0) and finalize with ~state.

fn (Crc32) checksum #

fn (c &Crc32) checksum(b []u8) u32

checksum returns the CRC-32 checksum of data b by using the polynomial represented by c's table.

fn (Crc32) update #

fn (c &Crc32) update(crc u32, b []u8) u32

update returns the updated CRC-32 checksum for b, starting from crc. Use crc = 0 for a fresh checksum, or pass a previous result to continue streaming.