hash::crc32 +linux +x86_64

Implements the CRC-32 checksum algorithm. It is a non-cryptographic checksum.



// Undocumented types:
type state;


const CASTAGNOLI: u32;
const IEEE: u32;
const KOOPMAN: u32;
const SIZE: size;


let castagnoli_table: [256]u32;
let ieee_table: [256]u32;
let koopman_table: [256]u32;


fn crc32(*[256]u32) state;
fn memoize(u32, *[256]u32) void;
fn sum32(*hash::hash) u32;


type state[link]

Show undocumented member
type state = struct {
	table: *[256]u32,
	cval: u32,


def CASTAGNOLI[link]

def CASTAGNOLI: u32;

Castagnoli polynomial for CRC-32. Used in iSCSI, SCTP, SSE4.2, btrfs, ext4, and others. It's known to have better error detection than IEEE.

def IEEE[link]

def IEEE: u32;

IEEE polynomial for CRC-32. Used in ethernet, SATA, MPEG-2, gzip, bzip2, cksum, PNG, etc. It is by far the most common polynomial used.

def KOOPMAN[link]

def KOOPMAN: u32;

Koopman polnomial for CRC-32. It has good performance for small datasets, but poor performance for large ones. Like the Castagnoli polynomial, it has better error detection than the IEEE polynomial.

def SIZE[link]

def SIZE: size;

The size, in bytes, of a CRC-32 checksum.


let castagnoli_table[link]

const castagnoli_table: [256]u32;

Table of memoized values for each byte with the Castagnoli polynomial.

let ieee_table[link]

const ieee_table: [256]u32;

Table of memoized values for each byte with the IEEE polynomial.

let koopman_table[link]

const koopman_table: [256]u32;

Table of memoized values for each byte with the Koopman polynomial.


fn crc32[link]

fn crc32(table: *[256]u32) state;

Creates a hash::hash which computes the CRC-32 algorithm. This hash function does not allocate any state, so you do not need to call hash::close when you are done with it.

It takes a table of memoized values for a given polynomail (for example, ieee_table, castagnoli_table, or koopman_table); a table for a custom polynomial, populated by memoize function, may also be used.

fn memoize[link]

fn memoize(polynomial: u32, buf: *[256]u32) void;

Populate a user-provided buffer with the memoized values for a custom polynomial.

The user-provided polynomial must be in the reversed form.

fn sum32[link]

fn sum32(h: *hash::hash) u32;

Returns the computed 32-bit CRC.