![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Replacment for Deprecated Crypt2 Compress FunctionsThe Chilkat Crypt2 compression functions are deprecated and will be removed. This example shows how to duplicate the functionality using the Chilkat Compression class.
Use ChilkatAx-win32.pkg Procedure Test Handle hoCrypt Handle hoSb Integer i Boolean iSuccess String sCompressedStr Variant vBd Handle hoBd Handle hoCompress String sDecompressedStr String sTemp1 Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt If (Not(IsComObjectCreated(hoCrypt))) Begin Send CreateComObject of hoCrypt End // Create data to be compressed. Get Create (RefClass(cComChilkatStringBuilder)) To hoSb If (Not(IsComObjectCreated(hoSb))) Begin Send CreateComObject of hoSb End Move 0 To i While (i < 25) Get ComAppend Of hoSb "Hello World, this is a test." + (character(13)) + (character(10)) To iSuccess Move (i + 1) To i Loop // Bzip2 compress the utf-8 byte representation of the string and return the compressed data as base64. Set ComCharset Of hoCrypt To "utf-8" Set ComEncodingMode Of hoCrypt To "base64" Get ComGetAsString Of hoSb To sTemp1 Get ComCompressStringENC Of hoCrypt sTemp1 To sCompressedStr Showln sCompressedStr // Result: 4aeUs+4CAABCWmgzMUFZJlNZZ6znBgAAfNeAABJABQBAAIAmZJwAIABwUNNMAAUqoekYjMp4ixF1FlFxF8i5i1FvFwizF9iwi9RdxaizF7RZi6i0ixF3Fui/i7kinChIM9ZzgwA= // The result contains an 8-byte header composed of a 4-byte magic number (0xB394A7E1) and a 4-byte length. // Do the following to BZip2 decompress using Chilkat Compression Get Create (RefClass(cComChilkatBinData)) To hoBd If (Not(IsComObjectCreated(hoBd))) Begin Send CreateComObject of hoBd End Get ComAppendEncoded Of hoBd sCompressedStr "base64" To iSuccess // Remove the 8-byte header. Get ComRemoveChunk Of hoBd 0 8 To iSuccess // Decompress Get Create (RefClass(cComChilkatCompression)) To hoCompress If (Not(IsComObjectCreated(hoCompress))) Begin Send CreateComObject of hoCompress End Set ComAlgorithm Of hoCompress To "bzip2" Get pvComObject of hoBd to vBd Get ComDecompressBd Of hoCompress vBd To iSuccess // Get the decompressed string. Get ComGetString Of hoBd "utf-8" To sDecompressedStr Showln sDecompressedStr End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.