hashers

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: 0BSD Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHashFuncExists     = fmt.Errorf("hasher already exists")
	ErrorHashFuncNotFound = fmt.Errorf("hasher not found")
)

Functions

func CRC32

func CRC32(file io.ReadCloser, expected string) (string, bool, error)

func FileToReader

func FileToReader(file string) (io.Reader, error)

Given a filename, return a reader for the file or an error if the file cannot be opened

func GuessHashType

func GuessHashType(hash string) string

func MD5

func MD5(file io.ReadCloser, expected string) (string, bool, error)

func Register

func Register(id string, function HashFunc) error

func SHA1

func SHA1(file io.ReadCloser, expected string) (string, bool, error)

func SHA256

func SHA256(file io.ReadCloser, expected string) (string, bool, error)

func SHA512

func SHA512(file io.ReadCloser, expected string) (string, bool, error)

Types

type CacheFile

type CacheFile struct {
	ID          string
	Destination string
	Hash        string
	HashType    string
}

func (CacheFile) Verify

func (cf CacheFile) Verify(ctx context.Context) (bool, error)

type HashFunc

type HashFunc func(io.ReadCloser, string) (string, bool, error)

TODO add Close() call

func GetHashFunc

func GetHashFunc(hashType string) (HashFunc, error)

Jump to

Keyboard shortcuts

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