![]() |
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
(Classic ASP) 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.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Crypt2") set crypt = Server.CreateObject("Chilkat.Crypt2") ' Create data to be compressed. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder") set sb = Server.CreateObject("Chilkat.StringBuilder") i = 0 Do While i < 25 success = sb.Append("Hello World, this is a test." & vbCrLf) i = i + 1 Loop ' Bzip2 compress the utf-8 byte representation of the string and return the compressed data as base64. crypt.Charset = "utf-8" crypt.EncodingMode = "base64" compressedStr = crypt.CompressStringENC(sb.GetAsString()) Response.Write "<pre>" & Server.HTMLEncode( compressedStr) & "</pre>" ' 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 ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData") set bd = Server.CreateObject("Chilkat.BinData") success = bd.AppendEncoded(compressedStr,"base64") ' Remove the 8-byte header. success = bd.RemoveChunk(0,8) ' Decompress ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Compression") set compress = Server.CreateObject("Chilkat.Compression") compress.Algorithm = "bzip2" success = compress.DecompressBd(bd) ' Get the decompressed string. decompressedStr = bd.GetString("utf-8") Response.Write "<pre>" & Server.HTMLEncode( decompressedStr) & "</pre>" %> </body> </html> |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.