Sample code for 30+ languages & platforms
Lua Requires Chilkat v11.0.0+

Create Password Protected Zip containing a Single File.

See more Zip Examples

Create a password-protected .zip containing a single file. (This uses the older Zip 2.0 encryption scheme, which is weaker and not as secure as AES encryption, which Chilkat Zip also supports.)

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

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

local zip = chilkat.Zip.new()

local success = zip:new_zip("test.zip")
if not success then
    print(zip.last_error_text)
    return
end

ERROR: Method not in Chilkat for Lua: Zip.SetPassword
zip:ERROR()
zip.password_protect = true

local saveExtraPath = false
success = zip:add_file("/temp/hamlet.xml", saveExtraPath)

success = zip:write_zip_and_close()
if not success then
    print(zip.last_error_text)
    return
end

print("Zip Created!")