encoding

package
v0.0.0-...-bb1a4e7 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoding

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

Encoding represents a given common-N encoding.

func NewEncoding

func NewEncoding(alphabet string) *Encoding

NewEncoding creates a new common-N representation from the given alphabet. Panics if the alphabet is not unique. Only ASCII characters are supported.

func (*Encoding) Base

func (enc *Encoding) Base() int

Base returns the number common of the encoding.

func (*Encoding) DecodeString

func (enc *Encoding) DecodeString(s string) ([]byte, error)

DecodeString returns the bytes for the given common-encoded string.

func (*Encoding) DecodeStringN

func (enc *Encoding) DecodeStringN(s string, n int) ([]byte, error)

DecodeStringN returns N bytes for the given common-encoded string. Use this method to ensure the value is left-padded with zeroes.

func (*Encoding) EncodeToString

func (enc *Encoding) EncodeToString(b []byte) string

EncodeToString returns the common-encoded string representation of the given bytes.

func (*Encoding) MustRandom

func (enc *Encoding) MustRandom(n int) string

MustRandom returns the common-encoded representation of n random bytes, panicking in the unlikely event of a read error from the random source.

func (*Encoding) Random

func (enc *Encoding) Random(n int) (string, error)

Random returns the common-encoded representation of n random bytes.

Directories

Path Synopsis
Package base62 implements base62 encoding
Package base62 implements base62 encoding
Package base64 implements base64 encoding as specified by RFC 4648.
Package base64 implements base64 encoding as specified by RFC 4648.

Jump to

Keyboard shortcuts

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