dreamworkAPI
Ctrl K
GitHub
libraryDocs / base64

base64

librarysharedmenusource

Base64 encoding/decoding library.

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

Classes & types

Functions

base64.alphabetCreates a base64 alphabet with encoding and decoding maps.
base64.decodeDecodes the specified base64 encoded string.
base64.encodeEncodes the specified string to base64.
base64.validateChecks if the specified base64 encoded string is valid, follows the same rules as base64.decode.

#base64.alphabet

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

Creates a base64 alphabet with encoding and decoding maps.

Parameters
NameTypeDescription
alphabet_strstringThe alphabet string, 64 unique non-whitespace characters.
Returns
TypeNameDescription
base64.AlphabetalphabetThe alphabet.

#base64.decode

sharedmenunodiscardsource
function base64.decode(base64_str: string, options?: base64.Options): string

Decodes the specified base64 encoded string.

Whitespace ( including line breaks ) is ignored, padding is optional but must be correct if present.

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

Parameters
NameTypeDescription
base64_strstringThe base64 encoded string to decode.
optionsoptionalbase64.OptionsThe base64 encoding options, default is the standard variant.
Returns
TypeNameDescription
stringraw_strThe decoded string.

#base64.encode

sharedmenunodiscardsource
function base64.encode(raw_str: string, options?: base64.Options): string

Encodes the specified string to base64.

Parameters
NameTypeDescription
raw_strstringThe string to encode.
optionsoptionalbase64.OptionsThe base64 encoding options, default is the standard variant.
Returns
TypeNameDescription
stringbase64_strThe encoded string.

#base64.validate

sharedmenunodiscardsource
function base64.validate(base64_str: string, options?: base64.Options): boolean, nil | string

Checks if the specified base64 encoded string is valid, follows the same rules as base64.decode.

Parameters
NameTypeDescription
base64_strstringThe base64 encoded string to check.
optionsoptionalbase64.OptionsThe base64 encoding options, default is the standard variant.
Returns
TypeNameDescription
booleanis_validtrue if the base64 string is valid, false otherwise
nil | stringerr_msgThe error message.
Generated from the dreamwork meta branch.