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.7k Golang : Calculations using complex numbers example
+6.7k Golang : Output or print out JSON stream/encoded data
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+7.3k Golang : How to convert strange string to JSON with json.MarshalIndent
+13.9k Golang : How to determine if a year is leap year?
+11.1k Golang : Roll the dice example
+3.7k Java : Random alphabets, alpha-numeric or numbers only string generator
+14.6k Golang : Convert(cast) int to float example
+19.3k Golang : Get RGBA values of each image pixel
+16.4k Golang : How to implement two-factor authentication?
+13.4k Golang : Increment string example
+8.8k Golang : On lambda, anonymous, inline functions and function literals