๐Ÿงฉ Base64 Guide

July 25, 2025 ยท View on GitHub

Lua API Difficulty Version

๐Ÿš€ 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

FunctionWhat it doesExample
dtw.base64_encode_file(path)Encode file to Base64dtw.base64_encode_file("file.png")
dtw.base64_encode(data)Encode string/binarydtw.base64_encode(image)
dtw.base64_decode(b64)Decode Base64 to binarydtw.base64_decode(b64)
dtw.write_file(path, data)Write binary to filedtw.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

Footer