hasher

package
v3.83.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package hasher provides a generic interface and base implementation for hashing data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blake2b

type Blake2b struct {
	// contains filtered or unexported fields
}

Blake2b implements the Hasher interface using Blake2b algorithm.

func NewBlake2B

func NewBlake2B() *Blake2b

NewBlake2B creates a new Blake2b hasher.

func (*Blake2b) Hash

func (b *Blake2b) Hash(data []byte) ([]byte, error)

Hash computes the hash of the given data. It returns an InputTooLargeError if the input data exceeds the maximum allowed size. This method resets the underlying hash before each computation to ensure that previous hashing operations do not affect the result.

type Hasher

type Hasher interface {
	// Hash takes input data and returns the hashed result.
	// It returns an error if the input data is too large.
	// The function is idempotent - calling it multiple times with the same input
	// will produce the same output, assuming the underlying hash function is deterministic.
	Hash(data []byte) ([]byte, error)
}

Hasher defines a generic interface for hashing data. Implementations of this interface may choose to be safe for concurrent use, but it is not a requirement. Users should check the documentation of specific implementations for concurrent safety guarantees.

type InputTooLargeError

type InputTooLargeError struct {
	// contains filtered or unexported fields
}

InputTooLargeError is returned when the input data exceeds the maximum allowed size.

func (*InputTooLargeError) Error

func (e *InputTooLargeError) Error() string

Jump to

Keyboard shortcuts

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