hash

package module
v0.0.0-...-120d1a5 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(value []byte) string

Format a handy function to convert value in bytes in string

func Print

func Print(w io.Writer, hash []byte, args ...interface{})

Print a handy function similar to fmt.Fprint which accept hash value as second arguments

Types

type Reader

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

func NewReader

func NewReader(r io.Reader) *Reader

NewReader creates parallel hashing with reading it is usuful if you want to read the reader and at the same time calculate the hash value of the read content

func (Reader) Hash

func (r Reader) Hash() Value

Hash generates the hash value of the read content NOTE: make sure to call this function once you finish reading it

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

type Value

type Value []byte

Value is a custom type which provides formating hash values with ease

func Bytes

func Bytes(content []byte) Value

Bytes hashes the given content in bytes and produces sha256

func ValueFromString

func ValueFromString(value string) (Value, error)

ValueFromString tries to parse the string version of value which was produced by calling String() methid back to type Value

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

func (*Value) Short

func (v *Value) Short() string

Short returns the last 5 characters of hash

func (*Value) String

func (v *Value) String() string

String returns the full string version of hash along with header

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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