1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 08:32:40 +08:00
This commit is contained in:
2022-03-29 09:40:33 +08:00
parent a5fb792dcf
commit 421e8e191b

View File

@ -7,6 +7,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"hash" "hash"
"hash/fnv"
"github.com/cespare/xxhash/v2" "github.com/cespare/xxhash/v2"
"github.com/spaolacci/murmur3" "github.com/spaolacci/murmur3"
@ -60,9 +61,21 @@ func XXhash(msg []byte) []byte {
} }
func XXHashUint64(msg []byte) uint64 { func XXHashUint64(msg []byte) uint64 {
d := xxhash.New() h := xxhash.New()
_, _ = d.Write(msg) _, _ = h.Write(msg)
return d.Sum64() 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 { func sum(f func() hash.Hash, msg []byte) []byte {