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
+14k Golang : convert rune to unicode hexadecimal value and back to rune character
+8.4k Golang : Ackermann function example
+19.6k Golang : Get current URL example
+18k Golang : How to log each HTTP request to your web server?
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+21.3k Golang : Create and resolve(read) symbolic links
+7.9k Golang : Get today's weekday name and calculate target day distance example
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+14.8k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+23k Golang : Calculate time different
+6.3k Javascript : Generate random key with specific length
+11.7k How to tell if a binary(executable) file or web application is built with Golang?