hash

package
v0.0.0-...-619fe92 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IBM         = 0xA001 // IBM 16-bit
	ARC         = 0x8005 // ARC
	AUG_CCITT   = 0x1021 // AUG-CCITT
	BUYPASS     = 0x8005 // BUYPASS
	CCITT_FALSE = 0x1021 // CCITT-FALSE
	CDMA2000    = 0xC867 // CDMA2000
	DDS_110     = 0x8005 // DDS-110
	DECT_R      = 0x0589 // DECT-R
	DECT_X      = 0x0589 // DECT-X
	DNP         = 0x3D65 // DNP
	EN_13757    = 0x3D65 // EN-13757
	GENIBUS     = 0x1021 // GENIBUS
	MAXIM       = 0x8005 // MAXIM
	MCRF4XX     = 0x1021 // MCRF4XX
	RIELLO      = 0x1021 // RIELLO
	T10_DIF     = 0x8BB7 // T10-DIF
	TELEDISK    = 0xA097 // TELEDISK
	TMS37157    = 0x1021 // TMS37157
	USB         = 0x8005 // USB
	CRC_A       = 0x1021 // CRC-A
	KERMIT      = 0x1021 // KERMIT
	MODBUS      = 0x8005 // MODBUS
	X_25        = 0x1021 // X-25
	XMODEM      = 0x1021 // XMODEM
)

Predefined polynomials.

View Source
const Size = 2

The size of a CRC-16 checksum in bytes.

Variables

View Source
var IBMTable = makeTable(IBM)

Functions

func Checksum

func Checksum(data []byte, tab *Table) uint16

Checksum returns the CRC-32 checksum of data using the polynomial represented by the Table.

func ChecksumIBM

func ChecksumIBM(data []byte) uint16

ChecksumIBM returns the CRC-16 checksum of data using the IBM polynomial.

func Update

func Update(crc uint16, tab *Table, p []byte) uint16

Update returns the result of adding the bytes in p to the crc.

Types

type Hash16

type Hash16 interface {
	hash.Hash
	Sum16() uint16
}

func New

func New(tab *Table) Hash16

New creates a new hash.Hash16 computing the CRC-16 checksum using the polynomial represented by the Table. Its Sum method will lay the value out in big-endian byte order. The returned Hash16 also implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler to marshal and unmarshal the internal state of the hash.

func NewIBM

func NewIBM() Hash16

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table is a 256-word table representing the polynomial for efficient processing.

func MakeTable

func MakeTable(poly uint16) *Table

Directories

Path Synopsis
Package crc16 is implementation according to CCITT standards.
Package crc16 is implementation according to CCITT standards.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL