Sample code for 30+ languages & platforms
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

Unicode C
#include <C_CkZipW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkZipW zip;
    BOOL passwordOk;

    success = FALSE;

    // 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);

    }