Documentation
¶
Index ¶
- Constants
- func HashStrings(ins ...string) digest.Digest
- type Hasher
- func (h *Hasher) Close()
- func (h *Hasher) DigestAndClose() string
- func (h *Hasher) WithByte(b byte) *Hasher
- func (h *Hasher) WithBytes(bs ...byte) *Hasher
- func (h *Hasher) WithDelim() *Hasher
- func (h *Hasher) WithFloat64(f float64) *Hasher
- func (h *Hasher) WithInt32(i int32) *Hasher
- func (h *Hasher) WithInt64(i int64) *Hasher
- func (h *Hasher) WithString(s string) *Hasher
Constants ¶
View Source
const (
XXH3 digest.Algorithm = "xxh3"
)
Variables ¶
This section is empty.
Functions ¶
func HashStrings ¶
func HashStrings(ins ...string) digest.Digest
HashStrings returns the xxh3 digest of the concatenation of the input strings, separated by null bytes to avoid collisions. It's more convenient than NewHasher when all inputs are already strings.
Types ¶
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher enables efficient hashing of mixed inputs of various types. It's intended for hot codepaths where minimizing allocations and overhead is important.
Inputs are separated by null bytes to avoid collisions (e.g. "ab" + "c" vs "a" + "bc").
NOTE: all the With* methods are mutating Hasher, so it can't "branch" off to compute different hashes. It also is not safe to use after Close or DigestAndClose have been called.
func (*Hasher) DigestAndClose ¶
func (*Hasher) WithFloat64 ¶
func (*Hasher) WithString ¶
Click to show internal directories.
Click to hide internal directories.