hasher

package
v0.0.0-...-03333d7 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDos2UnixHash

func NewDos2UnixHash(h hash.Hash) hash.Hash

NewDos2UnixHash returns a hash.Hash that wraps a hash.Hash while replacing '\r\n' with '\n' in the input. NOTE: calling Sum() will write '\r' if it was the last character seen. If an '\n' is written after the call to Sum() the output will be incorrect. Recommended to not write after Sum() is called.

Types

type Hash

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

Hash is a generic hash built from a hash.Hash and path transform function

func New

func New(hasher func() hash.Hash) *Hash

New returns a Hash object given a hash.Hash generator and path transform function

func (*Hash) IsValidKey

func (h *Hash) IsValidKey(key string) bool

IsValidKey return true if 'key' is a valid key to the hash

func (*Hash) New

func (h *Hash) New() hash.Hash

New returns a new instance of the underlying hash.Hash

func (*Hash) Sum

func (h *Hash) Sum(data []byte) (string, error)

Sum accepts a []byte of data and returns the sum

type Hasher

type Hasher interface {
	IsValidKey(string) bool
	New() hash.Hash
	Sum([]byte) (string, error)
}

Hasher is an interface representing both the hash function (returned by New()) and methods to verify hash keys and transform them before accessing the backend storage.

Jump to

Keyboard shortcuts

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