Standard library / hash/crc32

hash/crc32.New()

Create a streaming checksum with the selected polynomial. The digest bytes from Sum use big-endian order; Sum32 or Sum64 returns a number. The returned object supports binary state marshaling. This is not a cryptographic authentication primitive. Expected stdout: 'cbf43926\n'.

Formal Syntax & Structure

go syntaxgo
func New(tab *Table) hash.Hash32

Parameters & Attributes

NameTypeDescription
tab*TableRead-only lookup table for the chosen polynomial.

Return Value

hash.Hash32

Fresh incremental 32-bit hash.

Working Example

Example Snippetgo
package main
import (  "fmt"  "hash/crc32")
func main() {  h := crc32.New(crc32.MakeTable(crc32.IEEE))  h.Write([]byte("1234"))  h.Write([]byte("56789"))  fmt.Printf("%x\n", h.Sum(nil))}
Go Reference