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
+9.2k Golang : Write multiple lines or divide string into multiple lines
+4.6k Mac OSX : Get disk partitions' size, type and name
+5.2k Golang : Convert lines of string into list for delete and insert operation
+9.1k Golang : Get curl -I or head data from URL example
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+6.9k Fix sudo yum hang problem with no output or error messages
+31.9k Golang : Convert an image file to []byte
+10.1k Golang : How to tokenize source code with text/scanner package?
+24.5k Golang : Time slice or date sort and reverse sort example
+8.1k Golang : HTTP Server Example
+12.7k Golang : Add ASCII art to command line application launching process