Documentation ¶
Index ¶
- 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 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddBytes32 ¶
AddBytes32 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash
func AddBytes64 ¶
AddBytes64 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash
func AddString32 ¶
AddString32 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash
func AddString64 ¶
AddString64 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash
func Djb33 ¶
Djb33 比 FnvHash32 更快的获取字符串哈希值 djb2 with better shuffling. 5x faster than FNV with the hash.Hash overhead. Ref: patrickmn/go-cache
func GenHasher ¶
func GenHasher[K comparable]() func(K) uintptr
func GenHasher64 ¶
func GenHasher64[K comparable]() func(K) uint64
GenHasher64 按数据类型生成哈希函数 Ref: cespare/xxhash, smallnest/safemap, alphadose/haxmap, cornelk/hashmap
func GenSeedHasher64 ¶
func GenSeedHasher64[K comparable]() func(maphash.Seed, K) uint64
func HashBytes32 ¶
func HashBytes64 ¶
func HashSeedString ¶
HashSeedString calculates a hash of s with the given seed.
func HashSeedUint64 ¶
HashSeedUint64 calculates a hash of n with the given seed.
func HashString32 ¶
func HashString64 ¶
func HashUint32 ¶
HashUint32 returns the hash of u. Ref: segmentio/fasthash
func HashUint64 ¶
HashUint64 returns the hash of u. Ref: segmentio/fasthash
func HmacSHA1Hex ¶
func HmacSHA256 ¶
func HmacSHA256Hex ¶
func HmacSHA512 ¶
func HmacSHA512Hex ¶
func MD5BytesHex ¶
func MakeHasher ¶ added in v1.0.9
func MakeHasher[T comparable]() func(T) uint64
MakeHasher 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.