hash

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const SHA256HashSize = 32

SHA256HashSize holds the size of a sha256 hash in bytes.

Variables

This section is empty.

Functions

func EqHash

func EqHash(hash SHA256Hash) gomock.Matcher

Types

type SHA256Hash

type SHA256Hash [SHA256HashSize]byte

SHA256Hash is a SHA256 Hash over some bytes

func EmptyHash

func EmptyHash() SHA256Hash

EmptyHash returns a Hash that is empty (initialized with zeros).

func FromSlice

func FromSlice(slice []byte) SHA256Hash

FromSlice converts a byte slice to a Hash, returning a copy.

func ParseHex

func ParseHex(input string) (SHA256Hash, error)

ParseHex parses the given input string as Hash. If the input is invalid and can't be parsed as Hash, an error is returned.

func SHA256Sum

func SHA256Sum(data []byte) SHA256Hash

SHA256Sum creates a sha256 hash from the given bytes

func (SHA256Hash) Clone

func (h SHA256Hash) Clone() SHA256Hash

Clone returns a copy of the Hash.

func (SHA256Hash) Compare

func (h SHA256Hash) Compare(other SHA256Hash) int

Compare compares this Hash to another Hash using bytes.Compare.

func (SHA256Hash) Empty

func (h SHA256Hash) Empty() bool

Empty tests whether the Hash is empty (all zeros).

func (SHA256Hash) Equals

func (h SHA256Hash) Equals(other SHA256Hash) bool

Equals determines whether the given Hash is exactly the same (bytes match).

func (SHA256Hash) MarshalJSON

func (h SHA256Hash) MarshalJSON() ([]byte, error)

MarshalJSON marshals the hash as hex-encoded string

func (SHA256Hash) MarshalText

func (h SHA256Hash) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (SHA256Hash) Slice

func (h SHA256Hash) Slice() []byte

Slice returns the Hash as a slice. It does not copy the array.

func (SHA256Hash) String

func (h SHA256Hash) String() string

String returns the SHA256Hash as a hexadecimal string.

func (*SHA256Hash) UnmarshalJSON

func (h *SHA256Hash) UnmarshalJSON(data []byte) error

UnmarshalJSON converts from hex-encoded json value

Jump to

Keyboard shortcuts

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