valuehash

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package valuehash provides valuehashes.

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyHashError   = util.NewError("empty hash")
	InvalidHashError = util.NewError("invalid hash")
)

Functions

func SHA256Checksum

func SHA256Checksum(b []byte) string

Types

type Bytes

type Bytes []byte

func NewBytes

func NewBytes(b []byte) Bytes

func NewBytesFromString

func NewBytesFromString(s string) Bytes

func (Bytes) Bytes

func (hs Bytes) Bytes() []byte

func (Bytes) Equal

func (hs Bytes) Equal(h Hash) bool

func (Bytes) IsEmpty

func (hs Bytes) IsEmpty() bool

func (Bytes) IsValid

func (hs Bytes) IsValid([]byte) error

func (Bytes) MarshalBSONValue

func (hs Bytes) MarshalBSONValue() (bsontype.Type, []byte, error)

func (Bytes) MarshalJSON

func (hs Bytes) MarshalJSON() ([]byte, error)

func (Bytes) String

func (hs Bytes) String() string

func (*Bytes) UnmarshalBSONValue

func (hs *Bytes) UnmarshalBSONValue(t bsontype.Type, b []byte) error

func (*Bytes) UnmarshalJSON

func (hs *Bytes) UnmarshalJSON(b []byte) error

type Hash

type Hash interface {
	isvalid.IsValider
	util.Byter
	// NOTE usually String() value is the base58 encoded of Bytes()
	fmt.Stringer
	Equal(Hash) bool
	IsEmpty() bool
}

func Decode

func Decode(b []byte, enc encoder.Encoder) (Hash, error)

func RandomSHA256

func RandomSHA256() Hash

func RandomSHA256WithPrefix

func RandomSHA256WithPrefix(prefix []byte) Hash

RandomSHA256WithPrefix generate random hash with string-based prefix. To decode, it's structure is, - <8: length of bytes prefix><8: length of random hash><32: random hash><bytes prefix>

* 52 is max valid length of prefix

func RandomSHA512

func RandomSHA512() Hash

func RandomSHA512WithPrefix

func RandomSHA512WithPrefix(prefix []byte) Hash

RandomSHA512WithPrefix generate random hash with string-based prefix. To decode, it's structure is, - <8: length of bytes prefix><8: length of random hash><64: random hash><bytes prefix>

* 20 is max valid length of prefix

type HashGenerator

type HashGenerator interface {
	GenerateHash() Hash
}

type Hasher

type Hasher interface {
	Hash() Hash
}

type L32

type L32 [32]byte

func NewBlake3256

func NewBlake3256(b []byte) L32

func NewSHA256

func NewSHA256(b []byte) L32

func (L32) Bytes

func (h L32) Bytes() []byte

func (L32) Equal

func (h L32) Equal(b Hash) bool

func (L32) IsEmpty

func (h L32) IsEmpty() bool

func (L32) IsValid

func (h L32) IsValid([]byte) error

func (L32) MarshalBSONValue

func (h L32) MarshalBSONValue() (bsontype.Type, []byte, error)

func (L32) MarshalJSON

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

func (L32) String

func (h L32) String() string

type L64

type L64 [64]byte

func NewSHA512

func NewSHA512(b []byte) L64

func (L64) Bytes

func (h L64) Bytes() []byte

func (L64) Equal

func (h L64) Equal(b Hash) bool

func (L64) IsEmpty

func (h L64) IsEmpty() bool

func (L64) IsValid

func (h L64) IsValid([]byte) error

func (L64) MarshalBSONValue

func (h L64) MarshalBSONValue() (bsontype.Type, []byte, error)

func (L64) MarshalJSON

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

func (L64) String

func (h L64) String() string

Jump to

Keyboard shortcuts

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