crc64

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Zlib Imports: 4 Imported by: 0

Documentation

Overview

Package crc64 implements the 64-bit cyclic redundancy check, or CRC-64, checksum. See https://en.wikipedia.org/wiki/Cyclic_redundancy_check for information.

Polynomials are represented in LSB-first form, also known as reversed representation.

Checksums are layed out in big-endian byte order.

Index

Constants

View Source
const Size = 8

The size of a CRC-64 checksum in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

Hash is a hash.Hash64 that also implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler to marshal and unmarshal the internal state of the hash. Its Sum methods will lay the value out in big-endian byte order.

func New

func New(p *Poly) Hash

New creates a new Hash computing the CRC-64 checksum using the polynomial represented by the Poly.

type Poly

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

Poly represents a 64-bit polynomial with tables for efficient processing.

func ECMA

func ECMA() *Poly

ECMA returns the Poly representing the ECMA polynomial, defined in ECMA 182.

func ISO

func ISO() *Poly

ISO returns the Poly representing the ISO polynomial, defined in ISO 3309 and used in HDLC.

func MakePoly

func MakePoly(poly uint64) *Poly

MakePoly returns a Poly constructed from the specified polynomial given in LSB-first form, also known as reversed representation. The returned Poly may be shared and must not be modified.

func (*Poly) Checksum

func (p *Poly) Checksum(data []byte) uint64

Checksum returns the CRC-64 checksum of data in big-endian byte order.

func (*Poly) Combine

func (p *Poly) Combine(prev, next uint64, n int64) uint64

Combine returns the result of adding n bytes with the next sum to the prev sum.

func (*Poly) Polynomial

func (p *Poly) Polynomial() uint64

Polynomial returns the polynomial in LSB-first form, also known as reversed representation.

func (*Poly) Update

func (p *Poly) Update(sum uint64, data []byte) uint64

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

Jump to

Keyboard shortcuts

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