Sample code for 30+ languages & platforms
Tcl

Verify a Zip's Password

See more Zip Examples

Demonstrates how to verify the password for an encrypted or password-protected zip archive.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

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

set zip [new_CkZip]

# To verify a password for a Zip, the Zip must be opened:
set success [CkZip_OpenZip $zip "myProtected.zip"]
if {$success != 1} then {
    puts [CkZip_lastErrorText $zip]
    delete_CkZip $zip
    exit
}

# Set the password to be verified:
CkZip_put_DecryptPassword $zip "secret"

set passwordOk [CkZip_VerifyPassword $zip]
if {$passwordOk == 1} then {
    puts "Password is correct."
} else {
    puts "Password is incorrect."
}

CkZip_CloseZip $zip

delete_CkZip $zip