hashutil

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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 NewHasher

func NewHasher() *Hasher

func (*Hasher) Close

func (h *Hasher) Close()

func (*Hasher) DigestAndClose

func (h *Hasher) DigestAndClose() string

func (*Hasher) WithByte

func (h *Hasher) WithByte(b byte) *Hasher

func (*Hasher) WithBytes

func (h *Hasher) WithBytes(bs ...byte) *Hasher

func (*Hasher) WithDelim

func (h *Hasher) WithDelim() *Hasher

func (*Hasher) WithFloat64

func (h *Hasher) WithFloat64(f float64) *Hasher

func (*Hasher) WithInt32

func (h *Hasher) WithInt32(i int32) *Hasher

func (*Hasher) WithInt64

func (h *Hasher) WithInt64(i int64) *Hasher

func (*Hasher) WithString

func (h *Hasher) WithString(s string) *Hasher

Jump to

Keyboard shortcuts

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