hash

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeInvalid         = RegisterHashType(0x0, Metadata{Priority: -1, Name: "INVALID"})
	TypeSHA1            = RegisterHashType(0x1, Metadata{Priority: 1, Name: "SHA1", Size: sha1.Size, DigestSize: sha1.Size, New: sha1.New})
	TypeSHA256          = RegisterHashType(0x2, Metadata{Priority: 3, Name: "SHA256", Size: sha256.Size, DigestSize: sha256.Size, New: sha256.New})
	TypeSHA256Truncated = RegisterHashType(0x3, Metadata{Priority: 2, Name: "SHA256_TRUNCATED", Size: 20, DigestSize: sha256.Size, New: sha256.New})
	TypeSHA384          = RegisterHashType(0x4, Metadata{Priority: 4, Name: "SHA384", Size: sha512.Size384, DigestSize: sha512.Size384, New: sha512.New384})
	TypeSHA512          = RegisterHashType(0x5, Metadata{Priority: 5, Name: "SHA512", Size: sha512.Size, DigestSize: sha512.Size, New: sha512.New})
)

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Priority   int
	Name       string
	Size       uint8
	DigestSize uint8
	New        func() hash.Hash
	// contains filtered or unexported fields
}

type Type

type Type uint8

func RegisterHashType

func RegisterHashType(id uint8, metadata Metadata) Type

func (Type) DigestSize

func (hashType Type) DigestSize() uint8

func (Type) New

func (hashType Type) New() hash.Hash

func (Type) Priority

func (hashType Type) Priority() int

Priority returns the "rank" of this hash type to allow the "best" hash type to be found in a set of hash types.

A priority of zero or less means this hash MUST not be used.

func (Type) Size

func (hashType Type) Size() uint8

func (Type) String

func (hashType Type) String() string

func (Type) Valid

func (hashType Type) Valid() bool

Jump to

Keyboard shortcuts

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