Golang hash/crc32.Update function example

package hash/crc32

Update returns the result of adding the bytes in p to the crc.

Golang hash/crc32.Update function usage example

 package main

 import (
 "fmt"
 "hash/crc32"
 )

 var crcTable *crc32.Table

 func main() {

 checksum := crc32.Checksum([]byte("abcd"), crcTable)

 fmt.Printf("Checksum : %x \n", checksum)

 updatedchecksum := crc32.Update(checksum, crcTable, []byte("defg"))

 fmt.Printf("Updated Checksum : %x \n", updatedchecksum)

 }

Output :

Checksum : 92c80a31

Updated Checksum : 704eef2f

References :

http://golang.org/pkg/hash/crc32/#Update

https://www.socketloop.com/references/golang-hash-crc32-checksum-function-and-table-type-example

Advertisement