Golang hash/crc32.New and MakeTable functions example
package hash/crc32
New creates a new hash.Hash32 computing the CRC-32 checksum using the polynomial represented by the Table.
MakeTable returns the Table constructed from the specified polynomial.
Golang hash/crc32.New and MakeTable functions usage example
package main
import (
"fmt"
"hash/crc32"
)
var castagnoliTable = crc32.MakeTable(crc32.Castagnoli) // see http://golang.org/pkg/hash/crc32/#pkg-constants
func main() {
crc := crc32.New(castagnoliTable)
crc.Write([]byte("abcd"))
fmt.Printf("Sum32 : %x \n", crc.Sum32())
}
Output :
Sum32 : 92c80a31
References :
http://golang.org/pkg/hash/crc32/#pkg-constants
Advertisement
Something interesting
Tutorials
+15.6k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+17k Golang : Get input from keyboard
+6k Golang : Experimenting with the Rejang script
+51.4k Golang : Check if item is in slice/array
+5.6k Swift : Get substring with rangeOfString() function example
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+14.5k Golang : Overwrite previous output with count down timer
+8.6k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+5.3k Javascript : Shuffle or randomize array example
+12.7k Golang : Pass database connection to function called from another package and HTTP Handler
+9.3k Golang : How to get ECDSA curve and parameters data?