encoder

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alphabet

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

type BaseType

type BaseType int

BaseType defines supported base encoding formats.

const (
	Base58 BaseType = iota // Base58 encoding (commonly used in Bitcoin addresses)
	Base62                 // Base62 encoding (compact, URL-safe)
	Base64                 // Base64 encoding (standard in web/data transfer)
)

type Encoding

type Encoding interface {
	Encode([]byte) ([]byte, error)    // Encode input bytes to encoded bytes
	EncodeStr(string) (string, error) // Encode input string to encoded string
	Decode([]byte) ([]byte, error)    // Decode encoded bytes to original bytes
	DecodeStr(string) (string, error) // Decode encoded string to original string
}

Encoding defines a common interface for encoding and decoding operations. Implementations must support both byte-level and string-level operations.

func NewEncoding

func NewEncoding(base BaseType) Encoding

NewEncoding returns an Encoding implementation based on the selected BaseType. It supports Base58, Base62, and Base64 encodings. Returns nil if base is unsupported.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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