Cryptography

base64_encode

Encodes a Lua string's bytes with Base64 encoder, using = padding and no line breaks.

Syntax

base64_encode(data: string): string
Aliases base64encodebase64.encodecrypt.base64.encodecrypt.base64_encodecrypt.base64encode

Arguments

NameTypeDescription
datastringLua string bytes passed to Base64 encoder.

Returns

NameTypeDescription
encodedstringBase64 output returned as a Lua string.

Description

Encodes a Lua string's bytes with Base64 encoder, using = padding and no line breaks.

Call it with 1 parameter(s): data. The argument table explains which values are required and which ones only refine the behavior.

It returns encoded (string). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Encode a Lua string and print the Base64 output.

local encoded = base64_encode("hello world")

print(encoded)
print(base64encode("hello world"))
print(base64.encode("hello world"))