Sample code for 30+ languages & platforms
Xbase++

Verify a Zip's Password

See more Zip Examples

Demonstrates how to verify the password for an encrypted or password-protected zip archive.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oZip
LOCAL nPasswordOk

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oZip := CreateObject("Chilkat.Zip")

//  To verify a password for a Zip, the Zip must be opened:
nSuccess := oZip:OpenZip("myProtected.zip")
IF (nSuccess != 1)
    ? oZip:LastErrorText
    oZip:destroy()
    RETURN
ENDIF

//  Set the password to be verified:
oZip:DecryptPassword := "secret"

nPasswordOk := oZip:VerifyPassword()
IF (nPasswordOk == 1)
    ? "Password is correct."
ELSE
    ? "Password is incorrect."
ENDIF

oZip:CloseZip()

oZip:destroy()