sum

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Size = 32

Size is the byte-size of a checksum

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash struct {
	// contains filtered or unexported fields
}

Hash computes a checksum. Implements the `io.Writer` interface.

func New

func New() (*Hash, error)

New returns a new Hash.

func (*Hash) Sum

func (h *Hash) Sum() Sum

Sum returns the current checksum of a Hash.

func (*Hash) Write

func (h *Hash) Write(p []byte) (int, error)

Write writes a byte slice to the hash function.

type Sum

type Sum [Size]byte

Sum stores a checksum

func Compute

func Compute(data []byte) Sum

Compute returns the checksum of a byte slice.

func FromBase64

func FromBase64(s string) (Sum, error)

FromBase64 converts a base64 encoded string to a Sum.

func FromBytes

func FromBytes(b []byte) (Sum, error)

FromBytes converts a byte slice to a Sum. Its length must be sum.Size bytes.

func FromHex

func FromHex(s string) (Sum, error)

FromHex converts a hex string to a Sum.

func (Sum) AsHex

func (s Sum) AsHex() string

AsHex returns the hex-encoded representation of s.

Jump to

Keyboard shortcuts

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