hash

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 4 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashValues

func HashValues(hashAlgorithm crypto.Hash, values ...any) ([]byte, error)

Types

type Hash

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

func New

func New(h hash.Hash) *Hash

New creates "hash calculator" using given hash function. Values written to the hash are encoded as CBOR before hashing.

func NewSha256

func NewSha256() *Hash

func (*Hash) Reset

func (h *Hash) Reset()

func (*Hash) Size

func (h *Hash) Size() int

func (Hash) Sum

func (h Hash) Sum() ([]byte, error)

Sum returns the hash value calculated and first error (if any) that happened during the hashing (in case of non-nil error the hash value is not valid).

func (*Hash) Write

func (h *Hash) Write(v any)

Write serializes argument as CBOR and adds it to the hash.

func (*Hash) WriteRaw

func (h *Hash) WriteRaw(d []byte)

Write adds the argument as is (ie raw bytes, without additional encoding) to the hash.

type Hasher

type Hasher interface {
	Write(any)
	WriteRaw([]byte)
	Reset()
	Sum() ([]byte, error)
	Size() int
}

Jump to

Keyboard shortcuts

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