(DataFlex) Verify a Zip's Password
Demonstrates how to verify the password for an encrypted or password-protected zip archive.
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoZip
Boolean iSuccess
Boolean iPasswordOk
String sTemp1
// 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
|