crypt.base64encode
Encodes a string of bytes into Base64.
function crypt.base64encode(data: string): stringSynopsis
How it works
Encodes a raw binary string into Base64Base64A binary-to-text encoding that represents binary data as ASCII characters. Every 3 bytes become 4 characters from the alphabet A-Z, a-z, 0-9, +, /. Padding with = if input length isn't divisible by 3. using the standard RFC 4648 alphabet (
A–Z, a–z, 0–9, +, /) with = padding.Encoding process
Base64Base64A binary-to-text encoding that represents binary data as ASCII characters. Every 3 bytes become 4 characters from the alphabet A-Z, a-z, 0-9, +, /. Padding with = if input length isn't divisible by 3. processes input in 3-byte (24-bit) groups:
Input: [byte0] [byte1] [byte2]
Bits: xxxxxxxx yyyyyyyy zzzzzzzz
Split: xxxxxx xxyyyy yyyyzz zzzzzz
Output: [char0] [char1] [char2] [char3]
Each 6-bit group indexes into the 64-character alphabet. If the input length isn’t divisible by 3, the output is padded with = (one = for 2 remaining bytes, two == for 1). Output size is always ceil(input_len / 3) * 4 bytes — a ~33% expansion. Commonly used to safely embed binary data (encrypted blobs, images) in text-based formats like JSONJSONJavaScript Object Notation — a text-based data interchange format. Maps to Lua tables: objects → string-keyed tables, arrays → integer-keyed tables. Parsed via HttpService:JSONDecode() or game:GetService("HttpService"):JSONEncode()..Usage
Encode / decode round-trip
local b64 = crypt.base64encode("Hello, World!")
print(b64) "cc">--> SGVsbG8sIFdvcmxkIQ==
print(crypt.base64decode(b64)) "cc">--> Hello, World!Parameters
data string The raw bytes to encode.
Returns
string Base64-encoded string.
Aliases
crypt.base64.encode, crypt.base64_encode, base64.encode, base64_encode