base64encode Synchronous

  • base64.encode
  • base64_encode
  • crypt.base64.encode
  • crypt.base64_encode
  • crypt.base64encode
  • syn.crypt.base64.encode
  • syn.crypto.base64.encode

Turn arbitrary bytes into Base64 text. Use this when a JSON field, clipboard value, or other text-only channel needs to carry data that may contain zero bytes or nonprintable characters.

Syntax
Luau
base64encode(data: string) -> string

Parameters

Function parameters
ParameterTypeDescription
datastringThe byte string to encode. It can contain binary data; Luau strings do not need to be valid UTF-8 here.

Returns

string

Standard Base64 text with padding. Encoding changes the representation, not the secrecy or size of the original data.

Usage notes

Base64 is usually longer than the input. Decode it with base64decode before passing the bytes to an API that expects the original file or payload.

Example

Example
Luau
local bytes = "hello\0world"
local encoded = base64encode(bytes)
print(encoded)
assert(base64decode(encoded) == bytes)
Kawaii documentation