checksum

package
v0.0.0-...-0c53582 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileSha1Sum

func FileSha1Sum(filePath string) ([]byte, error)

FileSha1Sum returns the SHA1 checksum for the supplied file path

Types

type NoopHashWriter

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

NoopHashWriter implements Writer but doesn't actually calculate a checksum

func (*NoopHashWriter) Sum

func (hw *NoopHashWriter) Sum() []byte

Sum returns a dummy checksum

func (*NoopHashWriter) Write

func (hw *NoopHashWriter) Write(b []byte) (int, error)

WriteAt writes the byte slice at offset

type Sha1HashWriter

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

Sha1HashWriter implements Writer and uses the SHA1 algorithm to calculate the file checksum

func (*Sha1HashWriter) Sum

func (hw *Sha1HashWriter) Sum() []byte

Sum returns the checksum

func (*Sha1HashWriter) Write

func (hw *Sha1HashWriter) Write(b []byte) (int, error)

Write updates the checksum and writes the byte slice at offset

type Writer

type Writer interface {
	io.Writer
	Sum() []byte
}

Writer wraps an io.WriterAt and updates the checksum with every write.

func NewNoopHashWriter

func NewNoopHashWriter(dest io.Writer) Writer

NewNoopHashWriter returns a new NoopHashWriter

func NewSha1HashWriter

func NewSha1HashWriter(dest io.Writer) Writer

NewSha1HashWriter returns a new Sha1HashWriter

Jump to

Keyboard shortcuts

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