From 421e8e191b1bc2ff7b652024b8f7e0b5a0e0acf3 Mon Sep 17 00:00:00 2001 From: charlie <3140647@qq.com> Date: Tue, 29 Mar 2022 09:40:33 +0800 Subject: [PATCH] Funv --- hash/hash.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hash/hash.go b/hash/hash.go index 8b9ea18..2532286 100644 --- a/hash/hash.go +++ b/hash/hash.go @@ -7,6 +7,7 @@ import ( "encoding/base64" "encoding/hex" "hash" + "hash/fnv" "github.com/cespare/xxhash/v2" "github.com/spaolacci/murmur3" @@ -60,9 +61,21 @@ func XXhash(msg []byte) []byte { } func XXHashUint64(msg []byte) uint64 { - d := xxhash.New() - _, _ = d.Write(msg) - return d.Sum64() + h := xxhash.New() + _, _ = h.Write(msg) + return h.Sum64() +} + +func Funv32(msg []byte) uint32 { + h := fnv.New32() + _, _ = h.Write(msg) + return h.Sum32() +} + +func Funv64(msg []byte) uint64 { + h := fnv.New64() + _, _ = h.Write(msg) + return h.Sum64() } func sum(f func() hash.Hash, msg []byte) []byte {