Sample code for 30+ languages & platforms
Lua

UU Encoding and Decoding

See more Encryption Examples

Demonstrates how to UU encode and decode.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

local crypt = chilkat.Crypt2.new()

local s1 = "This string is to be UU encoded"

crypt.uu_mode = "666"
crypt.uu_filename = "something.txt"

-- UU encode:
local s2 = crypt:encode_string(s1, "ansi", "uu")

-- Note: Call crypt.Encode instead of crypt.EncodeString
-- to UU encode binary bytes (i.e. non-text binary data).

print(s2)

-- UU decode:
local crypt2 = chilkat.Crypt2.new()
local s3 = crypt2:decode_string(s2, "ansi", "uu")

-- Note: Likewise, call crypt.Decode to decode non-text binary data.

print(s3)

-- Show the file permissions mode and filename found
-- in the UU encoded data:
print("UuMode = " .. crypt2.uu_mode)
print("UuFilename = " .. crypt2.uu_filename)