hashlib

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: AGPL-3.0 Imports: 7 Imported by: 16

Documentation

Index

Constants

View Source
const (
	ContentHash = multihash.BLAKE2B_MAX
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash []byte

Hash is like multihash.Multihash but also supports serializing to json. It's methods are nil-value safe.

var (
	// EmptyHash is the hash of empty data, hashed with the default hash of ipfs.
	EmptyHash Hash

	// EmptyContent is like EmptyHash, but uses an zero blake2b hash.
	EmptyContent Hash
)

func Cast

func Cast(data []byte) (Hash, error)

func FromB58String

func FromB58String(b58 string) (Hash, error)

Create a new Hash from a b58 string. (This is shorthand for importing/using &Hash{multihash.FromB58String("xxx")}

func Sum

func Sum(data []byte) Hash

func TestDummy

func TestDummy(t *testing.T, seed byte) Hash

TestDummy returns a blake2b hash based on `seed`. The same `seed` will always generate the same hash.

func (Hash) B58String

func (h Hash) B58String() string

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes returns the underlying bytes in the hash.

func (Hash) Clone

func (h Hash) Clone() Hash

Clone returns the same hash as `h`, but with a different underlying array.

func (Hash) Equal

func (h Hash) Equal(other Hash) bool

Equal returns true if both hashes are equal. Nil hashes are considered equal.

func (Hash) ShortB58

func (h Hash) ShortB58() string

func (Hash) String

func (h Hash) String() string

func (Hash) UnmarshalJSON

func (h Hash) UnmarshalJSON(data []byte) error

UnmarshalJSON loads a base58 string representation of a hash and converts it to raw bytes.

func (Hash) Valid

func (h Hash) Valid() bool

Valid returns true if the hash contains a defined value.

func (Hash) Xor

func (h Hash) Xor(o Hash) error

type HashWriter

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

func NewHashWriter

func NewHashWriter() *HashWriter

func (*HashWriter) Hash

func (hw *HashWriter) Hash() Hash

func (*HashWriter) ReadFrom

func (hw *HashWriter) ReadFrom(r io.Reader) (int64, error)

func (*HashWriter) Write

func (hw *HashWriter) Write(buf []byte) (int, error)

Jump to

Keyboard shortcuts

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