Chilkat2-Python
Chilkat2-Python
Verify a Zip's Password
See more Zip Examples
Demonstrates how to verify the password for an encrypted or password-protected zip archive.Chilkat Chilkat2-Python Downloads
import sys
import chilkat2
success = False
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
zip = chilkat2.Zip()
# To verify a password for a Zip, the Zip must be opened:
success = zip.OpenZip("myProtected.zip")
if (success != True):
print(zip.LastErrorText)
sys.exit()
# Set the password to be verified:
zip.DecryptPassword = "secret"
passwordOk = zip.VerifyPassword()
if (passwordOk == True):
print("Password is correct.")
else:
print("Password is incorrect.")
zip.CloseZip()