Standard library / hash/crc32

hash/crc32.Update()

Extend an existing checksum with another chunk, using the same table as the earlier calculation. Starting at zero yields the ordinary checksum. This is not a cryptographic authentication primitive. Expected stdout: 'cbf43926\n'.

Formal Syntax & Structure

go syntaxgo
func Update(crc uint32, tab *Table, p []byte) uint32

Parameters & Attributes

NameTypeDescription
crcuint32Previously computed checksum; use zero to begin.
tab*TableRead-only lookup table for the chosen polynomial.
p[]byteAdditional input bytes.

Return Value

uint32

32-bit unsigned checksum.

Working Example

Example Snippetgo
package main
import (  "fmt"  "hash/crc32")
func main() {  t := crc32.MakeTable(crc32.IEEE)  v := crc32.Update(0, t, []byte("1234"))  v = crc32.Update(v, t, []byte("56789"))  fmt.Printf("%08x\n", v)}
Go Reference