Encodes a buffer into a Base64 string.
Uses the standard Base64 alphabet by default. Pass a custom 64-character
alphabet string to use a different encoding (e.g. URL-safe Base64 with
"-_" instead of "+/").
@eryx/encoding/base64 ModuleBase64 encoding utilities.
Encodes binary buffer data into the standard Base64 alphabet
(RFC 4648). A custom alphabet may be supplied for URL-safe or
other variants.
local base64 = require("@eryx/base64")
local encoded = base64.encode(buffer.fromstring("Hello, world!"))
print(encoded) -- "SGVsbG8sIHdvcmxkIQ=="
Encodes a buffer into a Base64 string.
Uses the standard Base64 alphabet by default. Pass a custom 64-character
alphabet string to use a different encoding (e.g. URL-safe Base64 with
"-_" instead of "+/").
The binary data to encode.
A custom 64-character alphabet string.
The Base64-encoded string.
Decodes a Base64 string back into a buffer.
Uses the standard Base64 alphabet by default. Pass the same custom alphabet that was used for encoding to decode URL-safe or other variants.
The Base64-encoded string.
A custom 64-character alphabet string.
The decoded binary data.
base64.STANDARD_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"base64.URL_SAFE_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"base64.IMAP_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,/"