Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples
Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Replacment for Deprecated Crypt2 Compress Functions

The Chilkat Crypt2 compression functions are deprecated and will be removed. This example shows how to duplicate the functionality using the Chilkat Compression class.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

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.