hash::crc16 +linux +x86_64

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



// Undocumented types:
type state;


const ANSI: u16;
const CCITT: u16;
const CMDA2000: u16;
const DECT: u16;
const SIZE: size;


let ansi_table: [256]u16;
let ccitt_table: [256]u16;
let cmda2000_table: [256]u16;
let dect_table: [256]u16;


fn crc16(*[256]u16) state;
fn memoize(u16, *[256]u16) void;

// Undocumented functions:
fn sum16(*hash::hash) u16;


type state[link]

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


def ANSI[link]

def ANSI: u16;

ANSI polynomial for CRC-16. Another widely used polynomial, it's seen in USB devices, Modbus, ANSI X3.28, and many others places. Also known as CRC-IBM.

def CCITT[link]

def CCITT: u16;

CRC-CCITT polynomial for CRC-16. The most commonly used polynomial, used in Bluetooth, X.25, XMODEM, and many other places. Also known as CRC-X25.

def CMDA2000[link]

def CMDA2000: u16;

CMDA200 polynomial for CRC-16. Used in the infrastructure of mobile networks.

def DECT[link]

def DECT: u16;

DECT polynomial for CRC-16. Typically used in cordless phones.

def SIZE[link]

def SIZE: size;

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


let ansi_table[link]

const ansi_table: [256]u16;

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

let ccitt_table[link]

const ccitt_table: [256]u16;

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

let cmda2000_table[link]

const cmda2000_table: [256]u16;

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

let dect_table[link]

const dect_table: [256]u16;

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


fn crc16[link]

fn crc16(table: *[256]u16) state;

Creates a hash::hash which computes the CRC-16 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, ccitt_table, dect_table, or ansi_table); a table for a custom polynomial, populated by memoize function, may also be used.

fn memoize[link]

fn memoize(polynomial: u16, buf: *[256]u16) 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 sum16[link]

Show undocumented member
fn sum16(h: *hash::hash) u16;