Sample code for 30+ languages & platforms
Lua

Base64 Encode/Decode a String

See more Encryption Examples

_LANGUAGE_ example to base-64 encode and decode a string.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local bd = chilkat.BinData.new()

local s = "A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump"

local success = bd:append_string(s, "utf-8")

local strBase64 = bd:get_encoded("base64")
print(strBase64)

-- To decode:
local bd2 = chilkat.BinData.new()
bd2:append_encoded(strBase64, "base64")

local decoded = bd2:get_string("utf-8")
print(decoded)