๐งฉ Base64 Guide
July 25, 2025 ยท View on GitHub
๐ Quick Start Guide for encoding and decoding Base64 with LuaDoTheWorld
๐ What You'll Learn
- โ How to encode a file to Base64
- โ How to decode Base64 back to a file
- โ How to encode/decode strings and binaries
๐ ๏ธ Prerequisites
- LuaDoTheWorld installed and required in your script
๐ค Encode a File to Base64
local dtw = require("luaDoTheWorld/luaDoTheWorld")
local b64 = dtw.base64_encode_file("tests/target/blob.png")
print(b64)
๐ Decode Base64 to File
local dtw = require("luaDoTheWorld/luaDoTheWorld")
local b64 = dtw.base64_encode_file("tests/target/blob.png")
local image = dtw.base64_decode(b64)
dtw.write_file("tests/target/blob2.png", image)
๐ Encode a String or Binary
local dtw = require("luaDoTheWorld/luaDoTheWorld")
local image = dtw.load_file("tests/target/blob.png")
local b64 = dtw.base64_encode(image)
print(b64)
๐ Quick Reference
| Function | What it does | Example |
|---|---|---|
dtw.base64_encode_file(path) | Encode file to Base64 | dtw.base64_encode_file("file.png") |
dtw.base64_encode(data) | Encode string/binary | dtw.base64_encode(image) |
dtw.base64_decode(b64) | Decode Base64 to binary | dtw.base64_decode(b64) |
dtw.write_file(path, data) | Write binary to file | dtw.write_file("out.png", data) |
๐ Need Help?
- ๐ Check the main SDK documentation
- ๐ Look at other example scripts in the SDK
- ๐ Report issues on our GitHub repository