![]() |
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
(AutoIt) 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.
$oCrypt = ObjCreate("Chilkat.Crypt2") ; Create data to be compressed. $oSb = ObjCreate("Chilkat.StringBuilder") Local $i = 0 While $i < 25 $oSb.Append("Hello World, this is a test." & @CRLF) $i = $i + 1 Wend ; Bzip2 compress the utf-8 byte representation of the string and return the compressed data as base64. $oCrypt.Charset = "utf-8" $oCrypt.EncodingMode = "base64" Local $sCompressedStr = $oCrypt.CompressStringENC($oSb.GetAsString()) ConsoleWrite($sCompressedStr & @CRLF) ; 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 $oBd = ObjCreate("Chilkat.BinData") $oBd.AppendEncoded($sCompressedStr,"base64") ; Remove the 8-byte header. $oBd.RemoveChunk(0,8) ; Decompress $oCompress = ObjCreate("Chilkat.Compression") $oCompress.Algorithm = "bzip2" $oCompress.DecompressBd($oBd) ; Get the decompressed string. Local $sDecompressedStr = $oBd.GetString("utf-8") ConsoleWrite($sDecompressedStr & @CRLF) |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.