Lua
Lua
Verify a Zip's Password
See more Zip Examples
Demonstrates how to verify the password for an encrypted or password-protected zip archive.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()
-- To verify a password for a Zip, the Zip must be opened:
local success = zip:open_zip("myProtected.zip")
if not success then
print(zip.last_error_text)
return
end
-- Set the password to be verified:
zip.decrypt_password = "secret"
local passwordOk = zip:verify_password()
if passwordOk then
print("Password is correct.")
else
print("Password is incorrect.")
end
zip:close_zip()