Unicode C++
Unicode C++
Verify a Zip's Password
See more Zip Examples
Demonstrates how to verify the password for an encrypted or password-protected zip archive.Chilkat Unicode C++ Downloads
#include <CkZipW.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkZipW zip;
// To verify a password for a Zip, the Zip must be opened:
success = zip.OpenZip(L"myProtected.zip");
if (success != true) {
wprintf(L"%s\n",zip.lastErrorText());
return;
}
// Set the password to be verified:
zip.put_DecryptPassword(L"secret");
bool passwordOk;
passwordOk = zip.VerifyPassword();
if (passwordOk == true) {
wprintf(L"Password is correct.\n");
}
else {
wprintf(L"Password is incorrect.\n");
}
zip.CloseZip();
}