dreamworkAPI
Ctrl K
GitHub
libraryDocs / base32

base32

librarysharedmenusource

Base32 encoding/decoding library.

See https://en.wikipedia.org/wiki/Base32

Classes & types

Functions

base32.alphabetCreates a base32 alphabet with encoding and decoding maps.
base32.decodeDecodes the specified base32 encoded string.
base32.encodeEncodes the specified string to base32.
base32.validateChecks if the specified base32 encoded string is valid.

#base32.alphabet

sharedmenunodiscardsource
function base32.alphabet(alphabet_str: string): base32.Alphabet

Creates a base32 alphabet with encoding and decoding maps.

Parameters
NameTypeDescription
alphabet_strstringThe alphabet string, 32 unique characters without =.
Returns
TypeNameDescription
base32.AlphabetalphabetThe alphabet.

#base32.decode

sharedmenunodiscardsource
function base32.decode(base32_str: string, ignore_padding?: boolean, alphabet?: ( "standard" | "extended" | base32.Alphabet )?): string

Decodes the specified base32 encoded string.

Throws an error if the string has invalid length, padding or characters.

Parameters
NameTypeDescription
base32_strstringThe base32 encoded string to decode.
ignore_paddingoptionalbooleanWhether padding is optional.
alphabetoptional( "standard" | "extended" | base32.Alphabet )?The alphabet to use.
Returns
TypeNameDescription
stringraw_strThe decoded string.

#base32.encode

sharedmenunodiscardsource
function base32.encode(raw_str: string, ignore_padding?: boolean, alphabet?: ( "standard" | "extended" | base32.Alphabet )?): string

Encodes the specified string to base32.

Parameters
NameTypeDescription
raw_strstringThe string to encode.
ignore_paddingoptionalbooleanWhether to ignore padding.
alphabetoptional( "standard" | "extended" | base32.Alphabet )?The alphabet to use.
Returns
TypeNameDescription
stringbase32_strThe encoded string.

#base32.validate

sharedmenunodiscardsource
function base32.validate(base32_str: string, ignore_padding?: boolean, alphabet?: ( "standard" | "extended" | base32.Alphabet )?): boolean, nil | string

Checks if the specified base32 encoded string is valid.

Parameters
NameTypeDescription
base32_strstringThe base32 encoded string to check.
ignore_paddingoptionalbooleanWhether padding is optional.
alphabetoptional( "standard" | "extended" | base32.Alphabet )?The alphabet to use.
Returns
TypeNameDescription
booleanis_validtrue if the base32 string is valid, false otherwise
nil | stringerr_msgThe error message.
Generated from the dreamwork meta branch.