digest

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHA1 digest.Algorithm = "sha1"
)

Variables

View Source
var (
	// Canonical is the primary digest algorithm used to calculate checksums.
	Canonical = digest.SHA256
)

Functions

func AlgorithmForName

func AlgorithmForName(name string) (digest.Algorithm, error)

AlgorithmForName returns the digest algorithm for the given name, or an error of type digest.ErrDigestUnsupported if the algorithm is unavailable.

Types

type MultiDigester

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

MultiDigester is a digester that writes to multiple digesters to calculate the checksum of different algorithms.

func NewMultiDigester

func NewMultiDigester(algos ...digest.Algorithm) (*MultiDigester, error)

NewMultiDigester returns a new MultiDigester that writes to newly initialized digesters for the given algorithms. If a provided algorithm is not available, it returns a digest.ErrDigestUnsupported error.

func (*MultiDigester) Digest

func (w *MultiDigester) Digest(algo digest.Algorithm) digest.Digest

Digest returns the digest of the data written to the digester of the given algorithm, or an empty digest if the algorithm is not available.

func (*MultiDigester) Write

func (w *MultiDigester) Write(p []byte) (n int, err error)

Write writes p to all underlying digesters.

Jump to

Keyboard shortcuts

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