Swift
Swift
Verify a Zip's Password
See more Zip Examples
Demonstrates how to verify the password for an encrypted or password-protected zip archive.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let zip = CkoZip()!
// To verify a password for a Zip, the Zip must be opened:
success = zip.open(zipPath: "myProtected.zip")
if success != true {
print("\(zip.lastErrorText!)")
return
}
// Set the password to be verified:
zip.decryptPassword = "secret"
var passwordOk: Bool
passwordOk = zip.verifyPassword()
if passwordOk == true {
print("Password is correct.")
}
else {
print("Password is incorrect.")
}
zip.close()
}