Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Encrypt Already Existing ZipTo encrypt an already existing non-encrypted .zip, the application must open the .zip, set the encryption related properties, and then re-write.
Use ChilkatAx-win32.pkg Procedure Test Handle hoZip Boolean iSuccess Integer iNumFilesUnzipped String sTemp1 // This requires the Chilkat Zip API to have been previously unlocked. // See Unlock Chilkat Zip for sample code. Get Create (RefClass(cComChilkatZip)) To hoZip If (Not(IsComObjectCreated(hoZip))) Begin Send CreateComObject of hoZip End // Open an unencrypted .zip Get ComOpenZip Of hoZip "qa_data/zips/test.zip" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // Unzip to a temp directory. Get ComUnzip Of hoZip "qa_output/tmp" To iNumFilesUnzipped If (iNumFilesUnzipped < 0) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // Clear the zip object. Get ComNewZip Of hoZip "qa_output/aesTest.zip" To iSuccess // Indicate that 128-bit AES encryption is to be used when writing the .zip Set ComEncryption Of hoZip To 4 Set ComEncryptKeyLength Of hoZip To 128 // Set the password. Set ComEncryptPassword Of hoZip To "secret" // Append the files. Set ComAppendFromDir Of hoZip To "qa_output/tmp" Get ComAppendFiles Of hoZip "*.*" True To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // Write the .zip and close it. Get ComWriteZipAndClose Of hoZip To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End Showln "Success." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.