|  | 
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) Compress Bytes to Base64 (or any other encoding)Compresses bytes to base64 or any other encoding. Also decompress to return the original. 
 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% ' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. ' First create some binary data to compress. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData") set binData = Server.CreateObject("Chilkat.BinData") For i = 1 To 16 success = binData.AppendEncoded("000102030405060708090A0B0C0D0E0F","hex") Next ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Compression") set compress = Server.CreateObject("Chilkat.Compression") compress.Algorithm = "deflate" compress.EncodingMode = "base64" uncompressedBytes = binData.GetBinary() ' Compress and return the compressed bytes in base64 format. compressedBase64 = compress.CompressBytesENC(uncompressedBytes) Response.Write "<pre>" & Server.HTMLEncode( "compressed and base64 encoded: " & compressedBase64) & "</pre>" ' Compress and return in hex format: compress.EncodingMode = "hex" compressedHex = compress.CompressBytesENC(uncompressedBytes) Response.Write "<pre>" & Server.HTMLEncode( "compressed and hex encoded: " & compressedHex) & "</pre>" ' Now decompress.. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData") set binData2 = Server.CreateObject("Chilkat.BinData") ' Decompress the base64.. compress.EncodingMode = "base64" uncompressedBytes = compress.DecompressBytesENC(compressedBase64) success = binData2.AppendBinary(uncompressedBytes) ' Show the uncompressed bytes in hex format: Response.Write "<pre>" & Server.HTMLEncode( binData2.GetEncoded("hex")) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "--") & "</pre>" ' Decompress the hex.. compress.EncodingMode = "hex" uncompressedBytes = compress.DecompressBytesENC(compressedHex) success = binData2.Clear() success = binData2.AppendBinary(uncompressedBytes) ' Show the uncompressed bytes in hex format: Response.Write "<pre>" & Server.HTMLEncode( binData2.GetEncoded("hex")) & "</pre>" Response.Write "<pre>" & Server.HTMLEncode( "--") & "</pre>" %> </body> </html> | ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.