hashutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HashEncoding   = NewEncoding(encoderHash)
	Base64Encoding = NewEncoding(encoderBase64)
)

Functions

This section is empty.

Types

type Encoding

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

Encoding implements alphabet-specific actions useful to hashes.

func NewEncoding

func NewEncoding(encoder string) *Encoding

NewEncoding returns a new Encoding defined by the given alphabet.

func (Encoding) Decode

func (enc Encoding) Decode(c byte) byte

Decode returns the index of c in the e alphabet, or 0xFF if c is not present in the e alphabet.

func (Encoding) Encode

func (enc Encoding) Encode(c byte) byte

Encode returns the character representing the c index of the e alphabet or 0xFF if the c index is not present in the e alphabet.

func (Encoding) IndexAnyInvalid

func (enc Encoding) IndexAnyInvalid(b []byte) int

IndexAnyInvalid returns the byte index of the first occurrence in b of any byte not from the e alphabet. It returns -1 if there is no invalid byte in b.

func (Encoding) Rand

func (enc Encoding) Rand(n int) []byte

Rand returns a string consisting of n cryptographically secure random characters from the e alphabet.

Jump to

Keyboard shortcuts

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