hash

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Zero256 = make([]byte, sha256.Size)

Functions

func HashValues

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

func Sum256

func Sum256(data []byte) []byte

Sum256 returns the SHA256 checksum of the data using the MessageHash augmented hashing.

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