hash

package
v0.0.0-...-b9de21a Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: LGPL-3.0 Imports: 6 Imported by: 31

Documentation

Index

Constants

View Source
const Hash256Size = 32

Hash256Size is 32 bytes

Variables

View Source
var (
	ErrInvalidHashSize   = errors.New("invalid hash size")
	ErrInvalidHashFormat = errors.New("invalid hash format")
)

hash256 errors

Functions

This section is empty.

Types

type Hash256

type Hash256 [Hash256Size]byte

Hash256 is the [Hash256Size]byte with methods

func DoubleHash

func DoubleHash(data []byte) Hash256

DoubleHash returns the result of Hash(Hash(data))

func DoubleHashByWriterTo

func DoubleHashByWriterTo(w io.WriterTo) Hash256

DoubleHashByWriterTo returns the result of Hash(io.Writer)

func Hash

func Hash(data []byte) Hash256

Hash returns the Hash256 value of the data

func MustParseHash

func MustParseHash(str string) Hash256

MustParseHash panic when error occurred

func MustParseHex

func MustParseHex(str string) Hash256

MustParseHex panics when parsing fails.

func ParseHash

func ParseHash(str string) (Hash256, error)

ParseHash parse the hash from the string

func ParseHex

func ParseHex(str string) (Hash256, error)

ParseHex parses the Hash256 from the hex string

func TwoHash

func TwoHash(h1 Hash256, h2 Hash256) Hash256

TwoHash returns the result of Hash(h1,'h',h2)

func (Hash256) Equal

func (hash Hash256) Equal(h Hash256) bool

Equal checks that two values is same or not

func (Hash256) MarshalJSON

func (hash Hash256) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (*Hash256) ReadFrom

func (hash *Hash256) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a desereialization function

func (Hash256) String

func (hash Hash256) String() string

String returns the hex string of the hash

func (*Hash256) UnmarshalJSON

func (hash *Hash256) UnmarshalJSON(bs []byte) error

UnmarshalJSON is a unmarshaler function

func (Hash256) WriteTo

func (hash Hash256) WriteTo(w io.Writer) (int64, error)

WriteTo is a sereialization function

Jump to

Keyboard shortcuts

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