checksum

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CRC16

func CRC16(data []byte) uint64

CRC16 computes CRC-16/CCITT with polynomial 0x1021 and initial value 0xFFFF.

func CRC32

func CRC32(data []byte) uint64

CRC32 computes CRC-32/ISO using Go's standard hash/crc32 with the IEEE polynomial.

func InternetChecksum

func InternetChecksum(data []byte) uint64

InternetChecksum computes the RFC 1071 internet checksum over data. It sums all 16-bit words, folds the carry bits, and returns the one's complement as uint64.

Types

type ChecksumFunc

type ChecksumFunc func(data []byte) uint64

ChecksumFunc is the signature for a checksum algorithm function. It takes a byte slice and returns a checksum value as uint64.

type ChecksumRegistry

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

ChecksumRegistry manages registered checksum algorithms.

func NewChecksumRegistry

func NewChecksumRegistry() *ChecksumRegistry

NewChecksumRegistry creates a new empty ChecksumRegistry.

func NewDefaultChecksumRegistry

func NewDefaultChecksumRegistry() *ChecksumRegistry

NewDefaultChecksumRegistry creates a ChecksumRegistry pre-loaded with all built-in checksum algorithms: internet-checksum, crc16, and crc32.

func (*ChecksumRegistry) Get

func (r *ChecksumRegistry) Get(name string) (ChecksumFunc, error)

Get retrieves a checksum algorithm by name. Returns AlgorithmNotFoundError if the algorithm is not registered.

func (*ChecksumRegistry) Has

func (r *ChecksumRegistry) Has(name string) bool

Has checks whether a checksum algorithm is registered.

func (*ChecksumRegistry) Register

func (r *ChecksumRegistry) Register(name string, fn ChecksumFunc)

Register adds a checksum algorithm to the registry.

Jump to

Keyboard shortcuts

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