hashenc

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 5 Imported by: 2

README

HashEncoder provides a means of quickly hash-summing and encoding data

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder interface {
	// Encode encodes the data at src into dst
	Encode(dst []byte, src []byte)

	// EncodedLen returns the encoded length for input data of supplied length
	EncodedLen(int) int
}

Encoder defines an interface for encoding binary data.

func Base32

func Base32() Encoder

Base32 returns a new base32 Encoder (StdEncoding, no padding).

func Base64

func Base64() Encoder

Base64 returns a new base64 Encoder (URLEncoding, no padding).

func Hex

func Hex() Encoder

Hex returns a new hex Encoder.

type HashEncoder

type HashEncoder interface {
	// EncodeSum calculates the hash sum of src and encodes (at most) Size() into dst
	EncodeSum(dst []byte, src []byte)

	// EncodedSum calculates the encoded hash sum of src and returns data in a newly allocated bytes.Bytes
	EncodedSum(src []byte) bytes.Bytes

	// Size returns the expected length of encoded hashes
	Size() int
}

HashEncoder defines an interface for calculating encoded hash sums of binary data

func New

func New(hash hash.Hash, enc Encoder) HashEncoder

New returns a new HashEncoder instance based on supplied hash.Hash and Encoder supplying functions.

Jump to

Keyboard shortcuts

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