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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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