input

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MD5 holds the identifier of the MD5 algorithm.
	MD5 = "md5"

	// SHA1 holds the identifier of the SHA1 algorithm.
	SHA1 = "sha1"

	// SHA256 holds the identifier of the SHA256 algorithm.
	SHA256 = "sha256"

	// SHA512 holds the identifier of the SHA512 algorithm.
	SHA512 = "sha512"

	// RIPEMD160 holds the identifier of the RIPEMD160 algorithm.
	RIPEMD160 = "ripemd160"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

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

Hash represents a set of input checksums calculated with several algorithms.

func NewHash

func NewHash() *Hash

NewHash returns a new instance of Hash with pre populated algorithms.

func (*Hash) Close

func (h *Hash) Close() error

Close implements io.Closer. Checksums will not be considered valid until Close() got called.

func (*Hash) Md5

func (h *Hash) Md5() string

Md5 returns the inputs MD5 checksums.

func (*Hash) Ripemd160

func (h *Hash) Ripemd160() string

Ripemd160 returns the inputs RIPEMD160 checksums.

func (*Hash) Sha1

func (h *Hash) Sha1() string

Sha1 returns the inputs SHA1 checksums.

func (*Hash) Sha256

func (h *Hash) Sha256() string

Sha256 returns the inputs SHA256 checksums.

func (*Hash) Sha512

func (h *Hash) Sha512() string

Sha512 returns the inputs SHA512 checksums.

func (*Hash) Sum

func (h *Hash) Sum(a string) string

Sum returns the inputs checksums for the given algorithm.

func (*Hash) Write

func (h *Hash) Write(p []byte) (n int, err error)

Write implements io.Writer and updates the all the checksums.

type Input

type Input interface {
	// Name returns the base name of the input file
	Name() string

	// Path returns the absolute path of the input file
	Path() string

	// Stem returns the inputs file name without the extension.
	// It will be used to create the file names of the output.
	Stem() string

	// Size returns the size of the input in bytes.
	// If the input size can not be determined, a negative number will be returned.
	Size() int64
}

Input describes an interface used by formats to get information about the input.

func NewFileInput

func NewFileInput(name, stem string) Input

NewFileInput creates an instance of Input representing a file input.

func NewStreamInput

func NewStreamInput(stem string) Input

NewStreamInput returns an instance of Input representing an input passed via STDIN.

Jump to

Keyboard shortcuts

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