## hash::crc16+x86_64 +linux

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

### Index

#### Types

// Undocumented types: type state = struct { hash::hash, table: *[256]u16, cval: u16, };

#### Constants

def ANSI: u16 = 40961; def CCITT: u16 = 33800; def CMDA2000: u16 = 58899; def DECT: u16 = 37280; def SZ: size = 2;

#### Globals

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

#### Functions

fn crc16(table: *[256]u16) state; fn memoize(polynomial: u16, buf: *[256]u16) void; // Undocumented functions: fn sum16(h: *hash::hash) u16;

### Types

#### type state[link]

## Show undocumented member

type state = struct { hash::hash, table: *[256]u16, cval: u16, };

### Constants

#### def ANSI[link]

def ANSI: u16 = 40961;

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 = 33800;

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 = 58899;

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

#### def DECT[link]

def DECT: u16 = 37280;

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

#### def SZ[link]

def SZ: size = 2;

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

### Globals

#### 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.

### Functions

#### 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;