crc16

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Unlicense Imports: 1 Imported by: 0

Documentation

Overview

Package crc16 implements the 16-bit cyclic redundancy check, or CRC-16, checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check and http://www.ross.net/crc/download/crc_v3.txt for information.

Index

Constants

View Source
const (
	IBM = 0x8005 // x^16 + x^15 + x^2 + x^0
)

Predefined polynomials.

View Source
const Size = 2

Size of a CRC-16 checksum in bytes.

Variables

View Source
var IBMTable = makeTable(IBM)

IBMTable is the table for the IBM polynomial.

Functions

func Checksum

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

Checksum returns the CRC-16 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 New

func New(table *Table) hashutil.Hash16

New creates a new hashutil.Hash16 computing the CRC-16 checksum using the polynomial represented by the Table.

func NewIBM

func NewIBM() hashutil.Hash16

NewIBM creates a new hashutil.Hash16 computing the CRC-16 checksum using the IBM polynomial.

func Update

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

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

Types

type Table

type Table [256]uint16

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

func MakeTable

func MakeTable(poly uint16) (table *Table)

MakeTable returns the Table constructed from the specified polynomial.

Jump to

Keyboard shortcuts

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