hash

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHash = sha256.New

DefaultHash is a default hashing algorithm - "sha256".

Functions

This section is empty.

Types

type Digest

type Digest struct {
	hash.Hash
}

Digest represents the partial evaluation of a checksum.

func New

func New() *Digest

New returns new hash from a given integer.

func (*Digest) Sum

func (d *Digest) Sum(b []byte) Hash

Sum appends the current checksum to b and returns the Hash.

func (*Digest) WriteObject

func (d *Digest) WriteObject(v interface{}) (int, error)

WriteObject adds an interface data to the running hash. It never retruns an error.

type Hash

type Hash []byte

A Hash is a type for representing hash with base58 encode and decode functions.

func Decode

func Decode(h string) (Hash, error)

Decode decodes the base58 encoded hash. It returns error when a hash isn't base58,encoded or hash length is invalid.

func Dump

func Dump(v interface{}) Hash

Dump takes an interface and returns its hash representation.

func Int

func Int(h int) Hash

Int returns a new hash from a given integer. NOTE: This method is for tests purpose only.

func Random

func Random() (Hash, error)

Random returns a new random hash.

func (Hash) Equal

func (h Hash) Equal(h1 Hash) bool

Equal returns a boolean reporting whether h and h1 are the same hashes.

func (Hash) IsZero

func (h Hash) IsZero() bool

IsZero reports whethere h represents empty hash.

func (Hash) String

func (h Hash) String() string

String returns the base58 hash representation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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