crc8

package
v0.0.0-...-c3c44a6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Copyright (c) 2018 The MATRIX Authors Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php Package crc8 implements the 8-bit cyclic redundancy check, or CRC-8, checksum.

It provides parameters for the majority of well-known CRC-8 algorithms.

Index

Constants

This section is empty.

Variables

View Source
var (
	CRC8          = Params{0x07, 0x00, false, false, 0x00, 0xF4, "CRC-8"}
	CRC8_CDMA2000 = Params{0x9B, 0xFF, false, false, 0x00, 0xDA, "CRC-8/CDMA2000"}
	CRC8_DARC     = Params{0x39, 0x00, true, true, 0x00, 0x15, "CRC-8/DARC"}
	CRC8_DVB_S2   = Params{0xD5, 0x00, false, false, 0x00, 0xBC, "CRC-8/DVB-S2"}
	CRC8_EBU      = Params{0x1D, 0xFF, true, true, 0x00, 0x97, "CRC-8/EBU"}
	CRC8_I_CODE   = Params{0x1D, 0xFD, false, false, 0x00, 0x7E, "CRC-8/I-CODE"}
	CRC8_ITU      = Params{0x07, 0x00, false, false, 0x55, 0xA1, "CRC-8/ITU"}
	CRC8_MAXIM    = Params{0x31, 0x00, true, true, 0x00, 0xA1, "CRC-8/MAXIM"}
	CRC8_ROHC     = Params{0x07, 0xFF, true, true, 0x00, 0xD0, "CRC-8/ROHC"}
	CRC8_WCDMA    = Params{0x9B, 0x00, true, true, 0x00, 0x25, "CRC-8/WCDMA"}
)

Predefined CRC-8 algorithms. List of algorithms with their parameters borrowed from here - http://reveng.sourceforge.net/crc-catalogue/1-15.htm#crc.cat-bits.8

The variables can be used to create Table for the selected algorithm.

Functions

func CalCRC8

func CalCRC8(data []byte) uint8

func Checksum

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

Checksum returns CRC checksum of data usign scpecified algorithm represented by the Table.

func Complete

func Complete(crc uint8, table *Table) uint8

Complete returns the result of CRC calculation and post-calculation processing of the crc.

func Init

func Init(table *Table) uint8

Init returns the initial value for CRC register corresponding to the specified algorithm.

func ReverseByte

func ReverseByte(val byte) byte

func ReverseUint16

func ReverseUint16(val uint16) uint16

func ReverseUint8

func ReverseUint8(val uint8) uint8

func Update

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

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

Types

type Params

type Params struct {
	Poly   uint8
	Init   uint8
	RefIn  bool
	RefOut bool
	XorOut uint8
	Check  uint8
	Name   string
}

Params represents parameters of a CRC-8 algorithm including polynomial and initial value. More information about algorithms parametrization and parameter descriptions can be found here - http://www.zlib.net/crc_v3.txt

type Table

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

Table is a 256-byte table representing polinomial and algorithm settings for efficient processing.

func MakeTable

func MakeTable(params Params) *Table

MakeTable returns the Table constructed from the specified algorithm.

Jump to

Keyboard shortcuts

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