base64encode Synchronous
base64.encodebase64_encodecrypt.base64.encodecrypt.base64_encodecrypt.base64encodesyn.crypt.base64.encodesyn.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.
Luau
base64encode(data: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
data | string | The byte string to encode. It can contain binary data; Luau strings do not need to be valid UTF-8 here. |
Returns
stringStandard 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
Luau
local bytes = "hello\0world"
local encoded = base64encode(bytes)
print(encoded)
assert(base64decode(encoded) == bytes)