hashutils

package
v0.12.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashAny

func HashAny(value any, hasher Hasher) uint64

HashAny hashes an arbitrary Go value (the result of json.Unmarshal) in a canonical way using the provided hasher. It returns a 64-bit non-cryptographic hash.

func HashJSON

func HashJSON(input []byte, hasher Hasher) (uint64, error)

HashJSON takes a blob of JSON, unmarshals it, and returns a 64-bit hash using the provided hasher. If there's an error unmarshaling, it returns 0 and the error.

Types

type Hasher

type Hasher interface {
	hash.Hash
	Sum64() uint64
}

Hasher is an interface that wraps a Sum64 method. Any hash implementation that implements Sum64 can be used with HashAny.

Jump to

Keyboard shortcuts

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