h2hash

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotSupported is returned when the hash is unsupported
	ErrNotSupported errNotSupported
	// ErrInvalidFormat is returned when the hash format is invalid
	ErrInvalidFormat errInvalidFormat
	// ErrKeyInvalid is returned when the hash key config is invalid
	ErrKeyInvalid errKeyInvalid
)

Functions

func KeyID

func KeyID(params string) string

KeyID computes a key id from params

Types

type Algs

type Algs interface {
	Register(b Builder)
	Get(id string) (Builder, bool)
}

Algs are a map of valid hash algorithms

type AlgsMap

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

func NewAlgsMap

func NewAlgsMap() *AlgsMap

func (*AlgsMap) Get

func (m *AlgsMap) Get(id string) (Builder, bool)

func (*AlgsMap) Register

func (m *AlgsMap) Register(b Builder)

type Builder

type Builder interface {
	ID() string
	Build(params string) (Hasher, error)
}

Builder constructs a new hasher from params

type Hasher

type Hasher interface {
	ID() string
	Hash(msg []byte) (string, error)
	Verify(msg []byte, msghash string) (bool, error)
}

Hasher is a hash interface

func FromParams

func FromParams(params string, algs Algs) (Hasher, error)

FromParams creates a hasher from params

type Verifier

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

Verifier verifies hashes

func NewVerifier added in v0.2.3

func NewVerifier() *Verifier

func (*Verifier) Register

func (v *Verifier) Register(hasher Hasher)

Register registers a Hasher

func (*Verifier) Verify

func (v *Verifier) Verify(msg []byte, msghash string) (bool, error)

Verify checks to see if the hash of the given msg matches the provided msghash

Directories

Path Synopsis
passhash

Jump to

Keyboard shortcuts

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