digestutils

package
v2.0.3-beta.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Sha256Hash digest.Algorithm = "sha256"
	Md5Hash    digest.Algorithm = "md5"
)

Variables

View Source
var (
	// Algorithms is used to check if an algorithm is supported.
	// If algo is not supported, Algorithms[algo] will return empty string.
	// Please don't use digest.Algorithm() to convert a string to digest.Algorithm.
	Algorithms = map[string]digest.Algorithm{
		Sha256Hash.String(): Sha256Hash,
		Md5Hash.String():    Md5Hash,
	}
)
View Source
var (
	ErrDigestNotMatch = errors.New("digest not match")
)

Functions

func CreateHash

func CreateHash(hashType string) hash.Hash

func HashFile

func HashFile(file string, hashType digest.Algorithm) string

HashFile computes hash value corresponding to hashType, hashType is from digestutils.Md5Hash and digestutils.Sha256Hash.

func Md5Bytes

func Md5Bytes(bytes []byte) string

func Md5Reader

func Md5Reader(reader io.Reader) string

func NewDigestReader

func NewDigestReader(log *logger.SugaredLoggerOnWith, reader io.Reader, digest ...string) (io.Reader, error)

func Parse

func Parse(digest string) []string

func Sha256

func Sha256(values ...string) string

func ToHashString

func ToHashString(h hash.Hash) string

Types

type DigestReader

type DigestReader interface {
	io.Reader
	Digest() string
}

Jump to

Keyboard shortcuts

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