Skip to content

Latest commit

Β 

History

History
77 lines (52 loc) Β· 1.97 KB

File metadata and controls

77 lines (52 loc) Β· 1.97 KB

🧩 Base64 Guide

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

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

Footer