Ruby
Ruby
Verify a Zip's Password
See more Zip Examples
Demonstrates how to verify the password for an encrypted or password-protected zip archive.Chilkat Ruby Downloads
require 'chilkat'
success = false
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
zip = Chilkat::CkZip.new()
# To verify a password for a Zip, the Zip must be opened:
success = zip.OpenZip("myProtected.zip")
if (success != true)
print zip.lastErrorText() + "\n";
exit
end
# Set the password to be verified:
zip.put_DecryptPassword("secret")
passwordOk = zip.VerifyPassword()
if (passwordOk == true)
print "Password is correct." + "\n";
else
print "Password is incorrect." + "\n";
end
zip.CloseZip()