hash

package
v0.0.0-...-d1e1776 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadDigest

type BadDigest struct {
	ExpectedMD5   string
	CalculatedMD5 string
}

BadDigest - Content-MD5 you specified did not match what we received.

func (BadDigest) Error

func (e BadDigest) Error() string

type Reader

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

Reader writes what it reads from an io.Reader to an MD5 and SHA256 hash.Hash. Reader verifies that the content of the io.Reader matches the expected checksums.

func NewReader

func NewReader(src io.Reader, size int64, md5Hex, sha256Hex string, actualSize int64, strictCompat bool) (*Reader, error)

NewReader returns a new hash Reader which computes the MD5 sum and SHA256 sum (if set) of the provided io.Reader at EOF.

func (*Reader) ActualSize

func (r *Reader) ActualSize() int64

ActualSize returns the pre-modified size of the object. DecompressedSize - For compressed objects.

func (*Reader) MD5

func (r *Reader) MD5() []byte

MD5 - returns byte md5 value

func (*Reader) MD5Base64String

func (r *Reader) MD5Base64String() string

MD5Base64String returns base64 encoded MD5sum value.

func (*Reader) MD5Current

func (r *Reader) MD5Current() []byte

MD5Current - returns byte md5 value of the current state of the md5 hash after reading the incoming content. NOTE: Calling this function multiple times might yield different results if they are intermixed with Reader.

func (*Reader) MD5HexString

func (r *Reader) MD5HexString() string

MD5HexString returns hex md5 value.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

func (*Reader) SHA256

func (r *Reader) SHA256() []byte

SHA256 - returns byte sha256 value

func (*Reader) SHA256HexString

func (r *Reader) SHA256HexString() string

SHA256HexString returns hex sha256 value.

func (*Reader) Size

func (r *Reader) Size() int64

Size returns the absolute number of bytes the Reader will return during reading. It returns -1 for unlimited data.

func (*Reader) Verify

func (r *Reader) Verify() error

Verify verifies if the computed MD5 sum and SHA256 sum are equal to the ones specified when creating the Reader.

type SHA256Mismatch

type SHA256Mismatch struct {
	ExpectedSHA256   string
	CalculatedSHA256 string
}

SHA256Mismatch - when content sha256 does not match with what was sent from client.

func (SHA256Mismatch) Error

func (e SHA256Mismatch) Error() string

Jump to

Keyboard shortcuts

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