hasher

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashOptions

type HashOptions struct {
	// NewHash is a function which returns a new hash.Hash instance.
	NewHash func() hash.Hash

	// MinLength is the minimum number of hash bytes that will be used to create a lookup identifier.
	MinLength int
}

HashOptions is used to specify custom hash options and should only be used by advanced users.

type Hasher

type Hasher interface {
	// CreateID is an idempotent method for creating a unique shortened identifier
	// for the provided binary value.
	CreateID(value []byte, collisions int) []byte
}

Hasher generates a unique binary identifier for a longer piece of binary data using an efficient, non-cryptographic hash function.

func NewHasher

func NewHasher() (Hasher, error)

NewHasher creates a new hasher instance. Default parameters are currently set to use the first 4-bytes of the 64-bit BLAKE2b, non-cryptographic hash. In the case of a collision, more bytes of the hash will be used for disambiguation but this happens in a minority of cases except for massively large data sets.

func NewHasherWithOptions

func NewHasherWithOptions(options HashOptions) (Hasher, error)

NewHasherWithOptions creates a Hash with custom options. Most users should just use NewHasher with the default values.

Jump to

Keyboard shortcuts

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