(Unicode C) Verify a Zip's Password
Demonstrates how to verify the password for an encrypted or password-protected zip archive.
#include <C_CkZipW.h>
void ChilkatSample(void)
{
HCkZipW zip;
BOOL success;
BOOL passwordOk;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
zip = CkZipW_Create();
// To verify a password for a Zip, the Zip must be opened:
success = CkZipW_OpenZip(zip,L"myProtected.zip");
if (success != TRUE) {
wprintf(L"%s\n",CkZipW_lastErrorText(zip));
CkZipW_Dispose(zip);
return;
}
// Set the password to be verified:
CkZipW_putDecryptPassword(zip,L"secret");
passwordOk = CkZipW_VerifyPassword(zip);
if (passwordOk == TRUE) {
wprintf(L"Password is correct.\n");
}
else {
wprintf(L"Password is incorrect.\n");
}
CkZipW_CloseZip(zip);
CkZipW_Dispose(zip);
}
|