Go hash/crc32 Package

Introduction

Hash functions in Go are broken into two categories: cryptographic and non-cryptographic.

The non-cryptographic hash functions can be found underneath the hash package and include adler32, crc32, crc64, and fnv.

Here's an example using crc32:

package main /*  w w  w .j  a  v  a  2s  .  c o m*/

import ( 
    "fmt" 
    "hash/crc32" 
) 

func main() { 
    // create a hasher 
    h  := crc32.NewIEEE() 
    // write our data to it 
    h.Write([]byte("test")) 
    // calculate the crc32 checksum 
    v  := h.Sum32() 
    fmt.Println(v) 
} 



PreviousNext

Related