PowerShell
PowerShell
Verify a Zip's Password
See more Zip Examples
Demonstrates how to verify the password for an encrypted or password-protected zip archive.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
$zip = New-Object Chilkat.Zip
# To verify a password for a Zip, the Zip must be opened:
$success = $zip.OpenZip("myProtected.zip")
if ($success -ne $true) {
$($zip.LastErrorText)
exit
}
# Set the password to be verified:
$zip.DecryptPassword = "secret"
$passwordOk = $zip.VerifyPassword()
if ($passwordOk -eq $true) {
$("Password is correct.")
}
else {
$("Password is incorrect.")
}
$zip.CloseZip()