import "github.com/fufuok/utils/xhash"- func AddBytes32(h uint32, b []byte) uint32
- func AddBytes64(h uint64, b []byte) uint64
- func AddString32(h uint32, s string) uint32
- func AddString64(h uint64, s string) uint64
- func AddUint32(h, u uint32) uint32
- func AddUint64(h uint64, u uint64) uint64
- func Djb33(s string) uint32
- func FastModulo(x, n uint32) uint32
- func FnvHash(s string) uint64
- func FnvHash32(s string) uint32
- func GenHasher[K comparable]() func(K) uintptr
- func GenHasher64[K comparable]() func(K) uint64
- func GenSeedHasher64[K comparable]() func(maphash.Seed, K) uint64
- func Hash(b []byte, h hash.Hash) []byte
- func HashBytes(b ...[]byte) string
- func HashBytes32(b ...[]byte) uint32
- func HashBytes64(b ...[]byte) uint64
- func HashSeedString(seed maphash.Seed, s string) uint64
- func HashSeedUint64(seed maphash.Seed, n uint64) uint64
- func HashString(s ...string) string
- func HashString32(s ...string) uint32
- func HashString64(s ...string) uint64
- func HashUint32(u uint32) uint32
- func HashUint64(u uint64) uint64
- func Hmac(b []byte, key []byte, h func() hash.Hash) []byte
- func HmacSHA1(b, key []byte) []byte
- func HmacSHA1Hex(s, key string) string
- func HmacSHA256(b, key []byte) []byte
- func HmacSHA256Hex(s, key string) string
- func HmacSHA512(b, key []byte) []byte
- func HmacSHA512Hex(s, key string) string
- func MD5(b []byte) []byte
- func MD5BytesHex(bs []byte) string
- func MD5Hex(s string) string
- func MD5Reader(r io.Reader) (string, error)
- func MD5Sum(filename string) (string, error)
- func MakeHasher[T comparable]() func(T) uint64
- func MakeSeed() uint64
- func MemHash(s string) uint64
- func MemHash32(s string) uint32
- func MemHashb(b []byte) uint64
- func MemHashb32(b []byte) uint32
- func MustMD5Sum(filename string) string
- func Sha1(b []byte) []byte
- func Sha1Hex(s string) string
- func Sha256(b []byte) []byte
- func Sha256Hex(s string) string
- func Sha512(b []byte) []byte
- func Sha512Hex(s string) string
- func Sum32(s string) uint32
- func Sum64(s string) uint64
- func SumBytes32(bs []byte) uint32
- func SumBytes64(bs []byte) uint64
- type Hashable
func AddBytes32(h uint32, b []byte) uint32AddBytes32 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash
func AddBytes64(h uint64, b []byte) uint64AddBytes64 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash
func AddString32(h uint32, s string) uint32AddString32 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash
func AddString64(h uint64, s string) uint64AddString64 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash
func AddUint32(h, u uint32) uint32AddUint32 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash
func AddUint64(h uint64, u uint64) uint64AddUint64 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash
func Djb33(s string) uint32Djb33 比 FnvHash32 更快的获取字符串哈希值 djb2 with better shuffling. 5x faster than FNV with the hash.Hash overhead. Ref: patrickmn/go-cache
func FastModulo(x, n uint32) uint32FastModulo calculates x % n without using the modulo operator (~4x faster). Reference: https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
func FnvHash(s string) uint64FnvHash 获取字符串的哈希值
func FnvHash32(s string) uint32FnvHash32 获取字符串的哈希值
func GenHasher[K comparable]() func(K) uintptrfunc GenHasher64[K comparable]() func(K) uint64GenHasher64 按数据类型生成哈希函数 Ref: cespare/xxhash, smallnest/safemap, alphadose/haxmap, cornelk/hashmap
func GenSeedHasher64[K comparable]() func(maphash.Seed, K) uint64func Hash(b []byte, h hash.Hash) []bytefunc HashBytes(b ...[]byte) stringHashBytes 合并 Bytes, 得到字符串哈希
func HashBytes32(b ...[]byte) uint32func HashBytes64(b ...[]byte) uint64func HashSeedString(seed maphash.Seed, s string) uint64HashSeedString calculates a hash of s with the given seed.
func HashSeedUint64(seed maphash.Seed, n uint64) uint64HashSeedUint64 calculates a hash of n with the given seed.
func HashString(s ...string) stringHashString 合并一串文本, 得到字符串哈希
func HashString32(s ...string) uint32func HashString64(s ...string) uint64func HashUint32(u uint32) uint32HashUint32 returns the hash of u. Ref: segmentio/fasthash
func HashUint64(u uint64) uint64HashUint64 returns the hash of u. Ref: segmentio/fasthash
func Hmac(b []byte, key []byte, h func() hash.Hash) []bytefunc HmacSHA1(b, key []byte) []bytefunc HmacSHA1Hex(s, key string) stringfunc HmacSHA256(b, key []byte) []bytefunc HmacSHA256Hex(s, key string) stringfunc HmacSHA512(b, key []byte) []bytefunc HmacSHA512Hex(s, key string) stringfunc MD5(b []byte) []bytefunc MD5BytesHex(bs []byte) stringfunc MD5Hex(s string) stringMD5Hex 字符串 MD5
func MD5Reader(r io.Reader) (string, error)MD5Reader 计算 MD5
func MD5Sum(filename string) (string, error)MD5Sum 文件 MD5
func MakeHasher[T comparable]() func(T) uint64MakeHasher creates a fast hash function for the given comparable type. The only limitation is that the type should not contain interfaces inside based on runtime.typehash.
func MakeSeed() uint64MakeSeed creates a random seed.
func MemHash(s string) uint64MemHash 使用内置的 memhash 获取字符串哈希值
func MemHash32(s string) uint32MemHash32 使用内置的 memhash 获取字符串哈希值
func MemHashb(b []byte) uint64MemHashb 使用内置的 memhash 获取哈希值
func MemHashb32(b []byte) uint32MemHashb32 使用内置的 memhash 获取哈希值
func MustMD5Sum(filename string) stringfunc Sha1(b []byte) []bytefunc Sha1Hex(s string) stringfunc Sha256(b []byte) []bytefunc Sha256Hex(s string) stringfunc Sha512(b []byte) []bytefunc Sha512Hex(s string) stringfunc Sum32(s string) uint32Sum32 获取字符串的哈希值
func Sum64(s string) uint64Sum64 获取字符串的哈希值
func SumBytes32(bs []byte) uint32SumBytes32 获取 bytes 的哈希值
func SumBytes64(bs []byte) uint64SumBytes64 获取 bytes 的哈希值
Hashable allowed map key types constraint
type Hashable interface {
// contains filtered or unexported methods
}Generated by gomarkdoc