crc16

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package crc16 implements the 16-bit cyclic redundancy check, or CRC-16, checksum.

Index

Constants

View Source
const (
	CCITTFalse = 0x1021
)

Predefined polynomials.

View Source
const Size = 4

The size of a CRC-16 checksum in bytes.

Variables

View Source
var CCITTFalseTable = simpleMakeTable(CCITTFalse)

CCITTFalseTable is the table for the CCITT-FALSE polynomial.

Functions

func Checksum

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

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

func ChecksumCCITTFalse

func ChecksumCCITTFalse(data []byte) uint16

ChecksumCCITTFalse returns the CRC-16 checksum of data using the CCITT-FALSE polynomial.

Types

type Hash16

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

Hash16 is the common interface implemented by all 16-bit hash functions.

func NewCCITTFalse

func NewCCITTFalse() Hash16

NewCCITTFalse creates a new Hash16 computing the CRC-16 checksum using the IEEE polynomial.

type Table

type Table [256]uint16

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

Jump to

Keyboard shortcuts

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