(PureBasic) Verify a Zip's Password
Demonstrates how to verify the password for an encrypted or password-protected zip archive.
IncludeFile "CkZip.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
zip.i = CkZip::ckCreate()
If zip.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; To verify a password for a Zip, the Zip must be opened:
success.i = CkZip::ckOpenZip(zip,"myProtected.zip")
If success <> 1
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
; Set the password to be verified:
CkZip::setCkDecryptPassword(zip, "secret")
passwordOk.i
passwordOk = CkZip::ckVerifyPassword(zip)
If passwordOk = 1
Debug "Password is correct."
Else
Debug "Password is incorrect."
EndIf
CkZip::ckCloseZip(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndProcedure
|