hash

package
v0.0.0-...-2f646e5 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ByteLen is the length of a Hash in bytes. It should be the same as noms's hash.ByteLen.
	ByteLen = 20

	// StringLen is the number of characters a Hash takes when turned into a string
	StringLen = 32
)

Variables

This section is empty.

Functions

func IsHash

func IsHash(str string) bool

func New

func New() hash.Hash

Types

type Hash

type Hash [ByteLen]byte

A Hash represents a hash with ByteLen bytes

func From

func From(b []byte) (h Hash, err error)

From turns b into a Hash. If len(b) != ByteLen, From will return an error

func Of

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

Of calculates the hash of data

func Parse

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

Parse a string as a Hash. Same as UnmarshalText

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) Format

func (h Hash) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Hash) Hash

func (h Hash) Hash() Hash

Hash implements Hashable since it's already a hash

func (Hash) MarshalText

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

MarshalText returns the string representation of h. Same as h.String()

func (*Hash) Set

func (h *Hash) Set(other Hash)

Sets h to other

func (Hash) String

func (h Hash) String() string

String turns the Hash into a string representation

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error

UnmarshalText parses a string hash

type Hashable

type Hashable interface {
	Hash() Hash
}

A Hashable can either produce a hash of itself, or is already a hash

Jump to

Keyboard shortcuts

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