hashtools

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound is returned when a hash tool cannot be found.
	ErrNotFound = errors.New("does not exist")
)

Functions

func AsMap

func AsMap() map[string]*HashTool

AsMap returns all HashTools in a map. The returned map must not be modified.

func New

func New(name string) (hash.Hash, error)

New returns a new hash.Hash with the given name.

func Register

func Register(hashTool *HashTool)

Register registers a new HashTool. This function may only be called in init() functions.

Types

type HashTool

type HashTool struct {
	Name string

	NewHash      func() hash.Hash
	CryptoHashID crypto.Hash

	DigestSize    int // in bytes
	BlockSize     int // in bytes
	SecurityLevel int // approx. attack complexity as 2^n

	Comment string
	Author  string
	// contains filtered or unexported fields
}

HashTool holds generic information about a hash tool.

func AsList

func AsList() []*HashTool

AsList returns all HashTools in a slice. The returned slice must not be modified.

func Get

func Get(name string) (*HashTool, error)

Get returns the HashTool with the given name.

func (*HashTool) LabeledHasher added in v0.3.0

func (ht *HashTool) LabeledHasher() lhash.Algorithm

LabeledHasher returns the corresponding labeled hashing algorithm.

func (*HashTool) New

func (ht *HashTool) New() hash.Hash

New returns a new hash.Hash instance of the hash tool.

func (*HashTool) With

func (ht *HashTool) With(changes *HashTool) *HashTool

With uses the original HashTool as a template for a new HashTool and returns the new HashTool.

Jump to

Keyboard shortcuts

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