hashing

package
v1.11.11-rc.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: BSD-3-Clause Imports: 5 Imported by: 38

Documentation

Index

Constants

View Source
const (
	HashLen = sha256.Size
	AddrLen = ripemd160.Size
)

Variables

View Source
var ErrInvalidHashLen = errors.New("invalid hash length")

Functions

func Checksum

func Checksum(bytes []byte, length int) []byte

Checksum creates a checksum of [length] bytes from the 256 bit hash of the byte slice.

Returns: the lower [length] bytes of the hash Panics if length > 32.

func ComputeHash160

func ComputeHash160(buf []byte) []byte

ComputeHash160 computes a cryptographically strong 160 bit hash of the input byte slice.

func ComputeHash256

func ComputeHash256(buf []byte) []byte

ComputeHash256 computes a cryptographically strong 256 bit hash of the input byte slice.

func PubkeyBytesToAddress

func PubkeyBytesToAddress(key []byte) []byte

Types

type Hash160

type Hash160 = [ripemd160.Size]byte

Hash160 A 160 bit long hash value.

func ComputeHash160Array

func ComputeHash160Array(buf []byte) Hash160

ComputeHash160Array computes a cryptographically strong 160 bit hash of the input byte slice.

func ToHash160

func ToHash160(bytes []byte) (Hash160, error)

type Hash256

type Hash256 = [HashLen]byte

Hash256 A 256 bit long hash value.

func ComputeHash256Array

func ComputeHash256Array(buf []byte) Hash256

ComputeHash256Array computes a cryptographically strong 256 bit hash of the input byte slice.

func ToHash256

func ToHash256(bytes []byte) (Hash256, error)

type Hasher

type Hasher interface {
	// Hash takes a string and computes its hash value.
	// Values must be computed deterministically.
	Hash([]byte) uint64
}

Hasher is an interface to compute a hash value.

Directories

Path Synopsis
Package hashingmock is a generated GoMock package.
Package hashingmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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