Sample code for 30+ languages & platforms
Perl

Verify a Zip's Password

See more Zip Examples

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

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

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

my $zip = Chilkat2::Zip->new;

# To verify a password for a Zip, the Zip must be opened:
my $success = $zip->OpenZip('myProtected.zip');
if (!$success) {
    print $zip->LastErrorText, "\n";
    exit;
}

# Set the password to be verified:
$zip->DecryptPassword('secret');

my $passwordOk = $zip->VerifyPassword();
if ($passwordOk) {
    print "Password is correct.\n";
} else {
    print "Password is incorrect.\n";
}

$zip->CloseZip();