hashtools

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: GPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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