CryptoSys API Library Manual

Example: Zlib.Deflate  Zlib.Inflate 

[VB6 equivalent: ZLIB_Deflate]

Dim strPlain As String
Dim strBack As String
Dim abPlain() As Byte
Dim abCompressed() As Byte
Dim nUncompLen As Integer

' COMPRESSSION (deflation)

' Set the plaintext message
strPlain = "hello, hello, hello. This is a 'hello world' message " & _
    "for the world, repeat, for the world."
' Convert to an array of bytes
abPlain = System.Text.Encoding.Default.GetBytes(strPlain)
nUncompLen = abPlain.Length

' Now compress plaintext
abCompressed = Zlib.Deflate(abPlain)
Console.WriteLine("Compressed " & abPlain.Length & " bytes to " & abCompressed.Length)

' DECOMPRESSSION (inflation)

' Uncompress the compressed data
' Note: we must know the uncompressed length here
abPlain = Zlib.Inflate(abCompressed, nUncompLen)

' Convert back to a string
strBack = System.Text.Encoding.Default.GetString(abPlain)
Console.WriteLine(strBack)

See Also:
Zlib.Deflate Method

[Contents] [Index]

[PREV: Example: Wipe.String ...]   [Contents]   [Index]   
   [NEXT: Error Codes...]

Copyright © 2001-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-05-20T13:01:10Z.