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
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+12k Golang : Convert a rune to unicode style string \u
+8.6k Golang : Set or add headers for many or different handlers
+4.7k Golang : How to pass data between controllers with JSON Web Token
+14.2k Golang : syscall.Socket example
+11k Golang : Generate random elements without repetition or duplicate
+5.4k Unix/Linux/MacOSx : How to remove an environment variable ?
+24k Golang : Find biggest/largest number in array
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+7.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package
+16.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file