Golang hash/fnv.New32, New32a, New64 and New64a functions example
package hash/fnv
New32 returns a new 32-bit FNV-1 hash.Hash.
New32a returns a new 32-bit FNV-1a hash.Hash.
New64 returns a new 64-bit FNV-1 hash.Hash.
New64a returns a new 64-bit FNV-1a hash.Hash.
Golang hash/fnv.New32, New32a, New64 and New64a functions usage example
package main
import (
"fmt"
"hash/fnv"
)
func main() {
hasher32 := fnv.New32()
hasher32.Write([]byte("abcd"))
fmt.Printf("Sum32 : %x\n", hasher32.Sum32())
hasher32a := fnv.New32a()
hasher32a.Write([]byte("abcd"))
fmt.Printf("Sum32a : %x\n", hasher32a.Sum32())
hasher64 := fnv.New64()
hasher64.Write([]byte("abcd"))
fmt.Printf("Sum64 : %x\n", hasher64.Sum64())
hasher64a := fnv.New64a()
hasher64a.Write([]byte("abcd"))
fmt.Printf("Sum64a : %x\n", hasher64a.Sum64())
}
Output :
Sum32 : b9de7375
Sum32a : ce3479bd
Sum64 : 2ed9327efb844f95
Sum64a : fc179f83ee0724dd
References :
http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vohashfunction
Advertisement
Something interesting
Tutorials
+8.4k Golang : Convert word to its plural form example
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+18.7k Unmarshal/Load CSV record into struct in Go
+8.8k Golang : Gorilla web tool kit schema example
+11.3k Golang : Characters limiter example
+12.3k Golang : Validate email address
+7.7k Golang : Mapping Iban to Dunging alphabets
+8k Golang : What fmt.Println() can do and println() cannot do
+31.7k Golang : How to convert(cast) string to IP address?
+9k Golang : Go as a script or running go with shebang/hashbang style
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+20.2k Golang : How to get struct tag and use field name to retrieve data?