xhash

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: MIT, MIT, MIT Imports: 19 Imported by: 5

README

xhash

import "github.com/fufuok/utils/xhash"

Index

func AddBytes32

func AddBytes32(h uint32, b []byte) uint32

AddBytes32 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash

func AddBytes64

func AddBytes64(h uint64, b []byte) uint64

AddBytes64 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash

func AddString32

func AddString32(h uint32, s string) uint32

AddString32 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash

func AddString64

func AddString64(h uint64, s string) uint64

AddString64 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash

func AddUint32

func AddUint32(h, u uint32) uint32

AddUint32 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash

func AddUint64

func AddUint64(h uint64, u uint64) uint64

AddUint64 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash

func Djb33

func Djb33(s string) uint32

Djb33 比 FnvHash32 更快的获取字符串哈希值 djb2 with better shuffling. 5x faster than FNV with the hash.Hash overhead. Ref: patrickmn/go-cache

func FnvHash

func FnvHash(s string) uint64

FnvHash 获取字符串的哈希值

func FnvHash32

func FnvHash32(s string) uint32

FnvHash32 获取字符串的哈希值

func GenHasher

func GenHasher[K comparable]() func(K) uintptr

func GenHasher64

func GenHasher64[K comparable]() func(K) uint64

GenHasher64 返回哈希函数 Ref: smallnest/safemap, alphadose/haxmap, cornelk/hashmap

func GenSeedHasher64

func GenSeedHasher64[K comparable]() func(maphash.Seed, K) uint64

func Hash

func Hash(b []byte, h hash.Hash) []byte

func HashBytes

func HashBytes(b ...[]byte) string

HashBytes 合并 Bytes, 得到字符串哈希

func HashBytes32

func HashBytes32(b ...[]byte) uint32

func HashBytes64

func HashBytes64(b ...[]byte) uint64

func HashSeedString

func HashSeedString(seed maphash.Seed, s string) uint64

HashSeedString calculates a hash of s with the given seed.

func HashSeedUint64

func HashSeedUint64(seed maphash.Seed, n uint64) uint64

HashSeedUint64 calculates a hash of n with the given seed.

func HashString

func HashString(s ...string) string

HashString 合并一串文本, 得到字符串哈希

func HashString32

func HashString32(s ...string) uint32

func HashString64

func HashString64(s ...string) uint64

func HashUint32

func HashUint32(u uint32) uint32

HashUint32 returns the hash of u. Ref: segmentio/fasthash

func HashUint64

func HashUint64(u uint64) uint64

HashUint64 returns the hash of u. Ref: segmentio/fasthash

func Hmac

func Hmac(b []byte, key []byte, h func() hash.Hash) []byte

func HmacSHA1

func HmacSHA1(b, key []byte) []byte

func HmacSHA1Hex

func HmacSHA1Hex(s, key string) string

func HmacSHA256

func HmacSHA256(b, key []byte) []byte

func HmacSHA256Hex

func HmacSHA256Hex(s, key string) string

func HmacSHA512

func HmacSHA512(b, key []byte) []byte

func HmacSHA512Hex

func HmacSHA512Hex(s, key string) string

func MD5

func MD5(b []byte) []byte

func MD5BytesHex

func MD5BytesHex(bs []byte) string

func MD5Hex

func MD5Hex(s string) string

MD5Hex 字符串 MD5

func MD5Reader

func MD5Reader(r io.Reader) (string, error)

MD5Reader 计算 MD5

func MD5Sum

func MD5Sum(filename string) (string, error)

MD5Sum 文件 MD5

func MemHash

func MemHash(s string) uint64

MemHash 使用内置的 memhash 获取字符串哈希值

func MemHash32

func MemHash32(s string) uint32

MemHash32 使用内置的 memhash 获取字符串哈希值

func MemHashb

func MemHashb(b []byte) uint64

MemHashb 使用内置的 memhash 获取哈希值

func MemHashb32

func MemHashb32(b []byte) uint32

MemHashb32 使用内置的 memhash 获取哈希值

func MustMD5Sum

func MustMD5Sum(filename string) string

func Sha1

func Sha1(b []byte) []byte

func Sha1Hex

func Sha1Hex(s string) string

func Sha256

func Sha256(b []byte) []byte

func Sha256Hex

func Sha256Hex(s string) string

func Sha512

func Sha512(b []byte) []byte

func Sha512Hex

func Sha512Hex(s string) string

func Sum32

func Sum32(s string) uint32

Sum32 获取字符串的哈希值

func Sum64

func Sum64(s string) uint64

Sum64 获取字符串的哈希值

func SumBytes32

func SumBytes32(bs []byte) uint32

SumBytes32 获取 bytes 的哈希值

func SumBytes64

func SumBytes64(bs []byte) uint64

SumBytes64 获取 bytes 的哈希值

type Hashable

Hashable allowed map key types constraint

type Hashable interface {
    // contains filtered or unexported methods
}

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBytes32

func AddBytes32(h uint32, b []byte) uint32

AddBytes32 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash

func AddBytes64

func AddBytes64(h uint64, b []byte) uint64

AddBytes64 adds the hash of b to the precomputed hash value h. Ref: segmentio/fasthash

func AddString32

func AddString32(h uint32, s string) uint32

AddString32 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash

func AddString64

func AddString64(h uint64, s string) uint64

AddString64 adds the hash of s to the precomputed hash value h. Ref: segmentio/fasthash

func AddUint32

func AddUint32(h, u uint32) uint32

AddUint32 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash

func AddUint64

func AddUint64(h uint64, u uint64) uint64

AddUint64 adds the hash value of the 8 bytes of u to h. Ref: segmentio/fasthash

func Djb33

func Djb33(s string) uint32

Djb33 比 FnvHash32 更快的获取字符串哈希值 djb2 with better shuffling. 5x faster than FNV with the hash.Hash overhead. Ref: patrickmn/go-cache

func FnvHash

func FnvHash(s string) uint64

FnvHash 获取字符串的哈希值

func FnvHash32

func FnvHash32(s string) uint32

FnvHash32 获取字符串的哈希值

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 Hash

func Hash(b []byte, h hash.Hash) []byte

func HashBytes

func HashBytes(b ...[]byte) string

HashBytes 合并 Bytes, 得到字符串哈希

func HashBytes32

func HashBytes32(b ...[]byte) uint32

func HashBytes64

func HashBytes64(b ...[]byte) uint64

func HashSeedString

func HashSeedString(seed maphash.Seed, s string) uint64

HashSeedString calculates a hash of s with the given seed.

func HashSeedUint64

func HashSeedUint64(seed maphash.Seed, n uint64) uint64

HashSeedUint64 calculates a hash of n with the given seed.

func HashString

func HashString(s ...string) string

HashString 合并一串文本, 得到字符串哈希

func HashString32

func HashString32(s ...string) uint32

func HashString64

func HashString64(s ...string) uint64

func HashUint32

func HashUint32(u uint32) uint32

HashUint32 returns the hash of u. Ref: segmentio/fasthash

func HashUint64

func HashUint64(u uint64) uint64

HashUint64 returns the hash of u. Ref: segmentio/fasthash

func Hmac

func Hmac(b []byte, key []byte, h func() hash.Hash) []byte

func HmacSHA1

func HmacSHA1(b, key []byte) []byte

func HmacSHA1Hex

func HmacSHA1Hex(s, key string) string

func HmacSHA256

func HmacSHA256(b, key []byte) []byte

func HmacSHA256Hex

func HmacSHA256Hex(s, key string) string

func HmacSHA512

func HmacSHA512(b, key []byte) []byte

func HmacSHA512Hex

func HmacSHA512Hex(s, key string) string

func MD5

func MD5(b []byte) []byte

func MD5BytesHex

func MD5BytesHex(bs []byte) string

func MD5Hex

func MD5Hex(s string) string

MD5Hex 字符串 MD5

func MD5Reader

func MD5Reader(r io.Reader) (string, error)

MD5Reader 计算 MD5

func MD5Sum

func MD5Sum(filename string) (string, error)

MD5Sum 文件 MD5

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.

func MakeSeed added in v1.0.9

func MakeSeed() uint64

MakeSeed creates a random seed.

func MemHash

func MemHash(s string) uint64

MemHash 使用内置的 memhash 获取字符串哈希值

func MemHash32

func MemHash32(s string) uint32

MemHash32 使用内置的 memhash 获取字符串哈希值

func MemHashb

func MemHashb(b []byte) uint64

MemHashb 使用内置的 memhash 获取哈希值

func MemHashb32

func MemHashb32(b []byte) uint32

MemHashb32 使用内置的 memhash 获取哈希值

func MustMD5Sum

func MustMD5Sum(filename string) string

func Sha1

func Sha1(b []byte) []byte

func Sha1Hex

func Sha1Hex(s string) string

func Sha256

func Sha256(b []byte) []byte

func Sha256Hex

func Sha256Hex(s string) string

func Sha512

func Sha512(b []byte) []byte

func Sha512Hex

func Sha512Hex(s string) string

func Sum32

func Sum32(s string) uint32

Sum32 获取字符串的哈希值

func Sum64

func Sum64(s string) uint64

Sum64 获取字符串的哈希值

func SumBytes32

func SumBytes32(bs []byte) uint32

SumBytes32 获取 bytes 的哈希值

func SumBytes64

func SumBytes64(bs []byte) uint64

SumBytes64 获取 bytes 的哈希值

Types

type Hashable

type Hashable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		~float32 | ~float64 | ~string | ~complex64 | ~complex128
}

Hashable allowed map key types constraint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL