lex64

package
v0.0.0-...-0a34a27 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package lex64 is a base64 variant that preserves lexicographic ordering of bytestrings. It does this by using the alphanumeric characters, _, . and - as the alphabet.

  • is used as padding since it is the smallest character.

The codec preserves order and has roundtrip equality.

This package has two versions of the alphabet. V2 is the default and is URL-safe. V1 is legacy and is not URL-safe.

Lex64 V2 is a base64 encoding using the following alphabet:

.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz

The padding character is '-', which precedes the characters above. Lex64, by default, omits the padding character from generated strings, but can be made to emit them and conform to rfc4648 (with a different alphabet).

Lex64 also supports the following legacy alphabet:

0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz

At time of writing (2023 Q1), the legacy alphabet is used in Karte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(encoding *base64.Encoding, src string) ([]byte, error)

Decode takes a lexicographic base64 string and converts it to an array of bytes.

func Encode

func Encode(encoding *base64.Encoding, src []byte) (string, error)

Encode takes an array of bytes and converts it to a UTF-8 string encoded in lexicographic base64.

func GetEncoding

func GetEncoding(s Scheme) (*base64.Encoding, error)

GetEncoding gets the encoding, parameterized by whether we want padding or not.

Types

type Scheme

type Scheme string

Scheme identifies the alphabet being used and whether or not it has padding.

const (
	V1Padding     Scheme = "v1+pad"
	V1            Scheme = "v1"
	V2Padding     Scheme = "v2+pad"
	V2            Scheme = "v2"
	DefaultScheme Scheme = V2
)

Jump to

Keyboard shortcuts

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