base92

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT, MIT Imports: 1 Imported by: 0

Documentation

Overview

Package base92 fork from https://github.com/teal-finance/BaseXX with customizable encoding alphabet.

Index

Constants

View Source
const (
	Radix = 92 // approximation of ceil(log(256)/log(base)).

)

Variables

View Source
var StdEncoding = NewEncoding(alphabet)

StdEncoding is the default encoding enc.

Functions

This section is empty.

Types

type Encoding

type Encoding struct {
	EncChars []byte
	DecMap   [128]int8
}

Encoding alphabet is an optimized form of the encoding characters.

func NewEncoding

func NewEncoding(encoder string) *Encoding

NewEncoding creates a new alphabet mapping.

It panics if the passed string does not meet all requirements: its length (in bytes) must be the same as the base, all runes must be valid ASCII characters, and all characters must be different. Encoder string with non-printable characters are accepted.

func (*Encoding) DecodeString

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

DecodeString decodes a Base92 string into binary bytes.

func (*Encoding) Encode

func (enc *Encoding) Encode(bin []byte) []byte

EncodeToString encodes binary bytes into a Base92 string.

func (*Encoding) EncodeToString

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

EncodeToString encodes binary bytes into Base92 bytes.

Jump to

Keyboard shortcuts

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