Lua Requires Chilkat v11.0.0+
Lua
Unzip an AES Encrypted Text File directly into a String Variable
See more Zip Examples
A common need is to unzip from an AES encrypted Zip archive directly into a string variable, such that the unencrypted file never resides on disk, even temporarily. This example shows how to do it.Chilkat Lua Downloads
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()
-- This example opens a WinZip-compatible AES encrypted
-- .zip that contains a single file: hamlet.xml.
-- It decrypts and unzips hamlet.xml directly into a string
-- variable.
ERROR: Method not in Chilkat for Lua: Zip.SetPassword
zip:ERROR()
local success = zip:open_zip("qa_data/hamlet.zip")
if not success then
print(zip.last_error_text)
return
end
local entry = chilkat.ZipEntry.new()
success = zip:entry_of("hamlet.xml", entry)
if not success then
print(zip.last_error_text)
return
end
-- lineEndingBehavior:
-- 0 = leave unchanged.
-- 1 = convert all to bare LF's
-- 2 = convert all to CRLF's
local lineEndingBehavior = 0
local srcCharset = "utf-8"
local xmlText = entry:unzip_to_string(lineEndingBehavior, srcCharset)
print(xmlText)