Documentation ¶
Overview ¶
Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, 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 ¶
const Size = 4
The size of a CRC-32 checksum in bytes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hash ¶
type Hash interface { hash.Hash32 encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Hash is a hash.Hash32 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.
type Poly ¶
type Poly struct {
// contains filtered or unexported fields
}
Poly represents a 32-bit polynomial with tables for efficient processing.
func Castagnoli ¶
func Castagnoli() *Poly
Castagnoli returns the Poly representing Castagnoli's polynomial, which is used in iSCSI. It has better error detection characteristics than IEEE. https://dx.doi.org/10.1109/26.231911
func IEEE ¶
func IEEE() *Poly
IEEE returns the Poly representing the IEEE polynomial, which is by far and away the most common CRC-32 polynomial. It's used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, ...
func Koopman ¶
func Koopman() *Poly
Koopman returns the Poly representing Koopman's polynomial. It has better error detection characteristics than IEEE. https://dx.doi.org/10.1109/DSN.2002.1028931
func MakePoly ¶
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) Combine ¶
Combine returns the result of adding n bytes with the next sum to the prev sum.
func (*Poly) Polynomial ¶
Polynomial returns the polynomial in LSB-first form, also known as reversed representation.