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
+11.9k Golang : How to parse plain email text and process email header?
+8.8k Golang : Heap sort example
+4.3k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+21.8k SSL : How to check if current certificate is sha1 or sha2
+6.9k Golang : Calculate BMI and risk category
+8.1k Golang : Randomize letters from a string example
+20.2k Golang : How to get own program name during runtime ?
+12.7k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+17.8k Golang : Defer function inside init()
+8.6k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+14.2k Elastic Search : Mapping date format and sort by date
+9.9k Golang : Sort and reverse sort a slice of integers