Sample code for 30+ languages & platforms
DataFlex

Verify a Zip's Password

See more Zip Examples

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

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoZip
    Boolean iPasswordOk
    String sTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatZip)) To hoZip
    If (Not(IsComObjectCreated(hoZip))) Begin
        Send CreateComObject of hoZip
    End

    // To verify a password for a Zip, the Zip must be opened:
    Get ComOpenZip Of hoZip "myProtected.zip" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoZip To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Set the password to be verified:
    Set ComDecryptPassword Of hoZip To "secret"

    Get ComVerifyPassword Of hoZip To iPasswordOk
    If (iPasswordOk = True) Begin
        Showln "Password is correct."
    End
    Else Begin
        Showln "Password is incorrect."
    End

    Send ComCloseZip To hoZip


End_Procedure