digestutils

package
v2.0.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 13 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(reader io.Reader, digest ...string) io.Reader

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