h2hash

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorNotSupported is returned when the hash is unsupported
	ErrorNotSupported errorNotSupported
	// ErrorInvalidFormat is returned when the hash format is invalid
	ErrorInvalidFormat errorInvalidFormat
	// ErrorKeyInvalid is returned when the hash key config is invalid
	ErrorKeyInvalid errorKeyInvalid
)

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 interface {
	Register(hasher Hasher)
	Verify(msg []byte, msghash string) (bool, error)
}

Verifier verifies hashes

type VerifierMap

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

func NewVerifierMap

func NewVerifierMap() *VerifierMap

func (*VerifierMap) Register

func (v *VerifierMap) Register(hasher Hasher)

Register registers a Hasher

func (*VerifierMap) Verify

func (v *VerifierMap) 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