algorithm

package
v0.0.0-...-5f8cf3a Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2019 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Crc8Configs = []Config{
		{0x07, 0x00, 0x00, false, false},
		{0x9B, 0xFF, 0x00, false, false},
		{0x39, 0x00, 0x00, true, true},
		{0xD5, 0x00, 0x00, false, false},
		{0x1D, 0xFF, 0x00, true, true},
		{0x1D, 0xFD, 0x00, false, false},
		{0x07, 0x00, 0x55, false, false},
		{0x31, 0x00, 0x00, true, true},
		{0x07, 0xFF, 0x00, true, true},
		{0x9B, 0x00, 0x00, true, true},
	}
	Crc16Configs = []Config{
		{0x1021, 0xFFFF, 0x0000, false, false},
		{0x8005, 0x0000, 0x0000, true, true},
		{0x1021, 0x1D0F, 0x0000, false, false},
		{0x8005, 0x0000, 0x0000, false, false},
		{0xC867, 0xFFFF, 0x0000, false, false},
		{0x8005, 0x800D, 0x0000, false, false},
		{0x0589, 0x0000, 0x0001, false, false},
		{0x0589, 0x0000, 0x0000, false, false},
		{0x3D65, 0x0000, 0xFFFF, true, true},
		{0x3D65, 0x0000, 0xFFFF, false, false},
		{0x1021, 0xFFFF, 0xFFFF, false, false},
		{0x8005, 0x0000, 0xFFFF, true, true},
		{0x1021, 0xFFFF, 0x0000, true, true},
		{0x8BB7, 0x0000, 0x0000, false, false},
		{0xA097, 0x0000, 0x0000, false, false},
		{0x8005, 0xFFFF, 0xFFFF, true, true},
		{0x1021, 0x0000, 0x0000, true, true},
		{0x8005, 0xFFFF, 0x0000, true, true},
		{0x1021, 0xFFFF, 0xFFFF, true, true},
		{0x1021, 0x0000, 0x0000, false, false},
	}
	Crc32Configs = []Config{
		{0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, true},
		{0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, false, false},
		{0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true},
		{0xA833982B, 0xFFFFFFFF, 0xFFFFFFFF, true, true},
		{0x04C11DB7, 0xFFFFFFFF, 0x00000000, false, false},
		{0x04C11DB7, 0x00000000, 0xFFFFFFFF, false, false},
		{0x814141AB, 0x00000000, 0x00000000, false, false},
		{0x04C11DB7, 0xFFFFFFFF, 0x00000000, true, true},
		{0x000000AF, 0x00000000, 0x00000000, false, false},
	}
)

Reference: http://crccalc.com/ http://www.sunshine2k.de/coding/javascript/crc/crc_js.html http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html

View Source
var (
	DefaultCrc8ConfigIndex  = 0
	DefaultCrc16ConfigIndex = 17
	DefaultCrc32ConfigIndex = 0
)

Functions

func AppendCrc16

func AppendCrc16(data []byte) []byte

func AppendCrc32

func AppendCrc32(data []byte) []byte

func AppendCrc8

func AppendCrc8(data []byte) []byte

func Crc16

func Crc16(data []byte) uint16

func Crc16Continue

func Crc16Continue(data []byte, prev uint16) (uint16, error)

func Crc16Impl

func Crc16Impl(data []byte, table []uint16, init uint16,
	refin bool, refout bool, xorout uint16) uint16

func Crc16Predefined

func Crc16Predefined(data []byte, configIndex int) (uint16, error)

func Crc32

func Crc32(data []byte) uint32

func Crc32Continue

func Crc32Continue(data []byte, prev uint32) (uint32, error)

func Crc32Impl

func Crc32Impl(data []byte, table []uint32, init uint32,
	refin bool, refout bool, xorout uint32) uint32

func Crc32Predefined

func Crc32Predefined(data []byte, configIndex int) (uint32, error)

func Crc8

func Crc8(data []byte) byte

func Crc8Continue

func Crc8Continue(data []byte, prev byte) (byte, error)

func Crc8Impl

func Crc8Impl(data []byte, table []byte, init byte,
	refin bool, refout bool, xorout byte) byte

func Crc8Predefined

func Crc8Predefined(data []byte, configIndex int) (byte, error)

func MakeCrc16Table

func MakeCrc16Table(poly uint16) []uint16

func MakeCrc32Table

func MakeCrc32Table(poly uint32) []uint32

func MakeCrc8Table

func MakeCrc8Table(poly byte) []byte

func VerifyCrc16

func VerifyCrc16(data []byte) bool

func VerifyCrc32

func VerifyCrc32(data []byte) bool

func VerifyCrc8

func VerifyCrc8(data []byte) bool

Types

type Config

type Config struct {
	Polynomial uint32
	InitValue  uint32
	XorResult  uint32
	ReflectIn  bool
	ReflectOut bool
}

type InvalidIndexError

type InvalidIndexError int

func (InvalidIndexError) Error

func (e InvalidIndexError) Error() string

Jump to

Keyboard shortcuts

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