crc8

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Unlicense Imports: 1 Imported by: 0

Documentation

Overview

Package crc8 implements the 8-bit cyclic redundancy check, or CRC-8, 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 (
	ATM = 0x07 // x^8 + x^2 + x + 1
)

Predefined polynomials.

View Source
const Size = 1

Size of a CRC-8 checksum in bytes.

Variables

View Source
var ATMTable = makeTable(ATM)

ATMTable is the table for the ATM polynomial.

Functions

func Checksum

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

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

func ChecksumATM

func ChecksumATM(data []byte) uint8

ChecksumATM returns the CRC-8 checksum of data using the ATM polynomial.

func New

func New(table *Table) hashutil.Hash8

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

func NewATM

func NewATM() hashutil.Hash8

NewATM creates a new hashutil.Hash8 computing the CRC-8 checksum using the ATM polynomial.

func Update

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

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

Types

type Table

type Table [256]uint8

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

func MakeTable

func MakeTable(poly uint8) (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