sha256key

package
v0.0.0-...-70e5bc8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

Overview

Package sha256key provides access to the hash function used to make content-addressable keys.

Index

Constants

View Source
const Size = sha256.Size

Size is the number of bytes in a hash.

Variables

This section is empty.

Functions

func BytesString

func BytesString(hash []byte) string

BytesString returns a string representation of the hash that is represented in bytes.

Types

type Hash

type Hash [Size]byte // SHA-256 hash always 32 bytes

Hash represents a SHA-256 hash code. It is always 32 bytes long. Its representation is an array so it can be treated as a value.

var ZeroHash Hash

ZeroHash is the zero-valued hash.

func Of

func Of(data []byte) (hash Hash)

Of returns the SHA-256 hash of the data, as a Hash. The odd name works well in the client: sha256key.Of.

func Parse

func Parse(str string) (hash Hash, err error)

Parse returns the hash whose standard format (possibly absent the brackets) is the value of str.

func (Hash) EqualString

func (hash Hash) EqualString(b string) bool

EqualString compares the byte-level representation of a hash with its hex string representation, avoiding allocation.

func (Hash) String

func (hash Hash) String() string

String returns a hexadecimal representation of the hash.

Jump to

Keyboard shortcuts

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