iohash

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: MIT Imports: 7 Imported by: 0

README

go-iohash

Use iohash to generate a hash from the IO of an io.Reader or io.Writer. It simply wraps an existing io.Reader or io.Writer and additionaly feeds the io to a wrapped hash.

Examples

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMismatch = errors.New("checksum mismatch")
View Source
var ErrNotFound = errors.New("no checksum found")

Functions

func Check added in v0.0.2

func Check(rdr io.Reader, h hash.Hash, targetFile string) error

Check verifies the checksum of targetFile. The hash from the first line matching the targetFile is checked. Any succeeding lines are ignored. The line format is the output from #PrintHash, which is similar to the unix coreutils commands e.g `sha1` `sha512` ...

func CheckFile added in v0.0.2

func CheckFile(checksumsFile string, h hash.Hash, filename string) error

See description of iohash.Check.

func PrintHash added in v0.0.2

func PrintHash(w io.Writer, h hash.Hash, filename string) (int, error)

func StringOfHash

func StringOfHash(h hash.Hash) string

Types

type HashReader

type HashReader struct {
	io.Reader
	hash.Hash
}

func NewReader

func NewReader(r io.Reader, h hash.Hash) *HashReader

func (*HashReader) Read

func (h *HashReader) Read(p []byte) (int, error)

func (HashReader) String added in v0.0.2

func (h HashReader) String() string

type HashWriter

type HashWriter struct {
	io.Writer
	hash.Hash
}

func NewWriter

func NewWriter(w io.Writer, h hash.Hash) *HashWriter

func (HashWriter) String added in v0.0.2

func (h HashWriter) String() string

func (*HashWriter) Write

func (h *HashWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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