crc

package
v0.0.0-...-3a25cc1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const Polynomial uint32 = 0x04C11DB7

Variables

View Source
var Table = func(polynomial uint64) [256]uint32 {
	polynomialDivision := func(polynomial, input uint64, len uint) uint64 {
		mask := uint64(1)<<len - 1

		for i := uint(0); i < len; i++ {
			bitOut := input>>(len-1) > 0
			input <<= 1
			if bitOut {
				input ^= polynomial
			}
			input &= mask
		}

		return input
	}
	var table [256]uint32
	for i := 0; i < 256; i++ {
		table[i] = uint32(polynomialDivision(polynomial, uint64(i), 32))
	}
	return table
}(uint64(Polynomial))

Functions

func CalculateCRC

func CalculateCRC(buf []byte) uint32

Types

type CRC

type CRC uint32
const InitialValue CRC = 0xFFFFFFFF

func NewCRC

func NewCRC() CRC

func (*CRC) Sum32

func (c *CRC) Sum32() uint32

func (*CRC) Update

func (c *CRC) Update(buf []byte)

func (*CRC) UpdateUint32

func (c *CRC) UpdateUint32(data uint32)

Jump to

Keyboard shortcuts

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