Home > Language Reference > Classes > StreamCipher
InitZip Method
Sets the encoding/decoding scheme to Deflate.
Syntax
Public Sub InitZip(ByVal iCompression As Integer)
| Parameter | Description |
| iCompression | Compression rate. |
Remarks
The InitZip method sets the encoding/decoding scheme to Deflate, and allocates the necessary internal buffers. If the object was already initialized, buffers allocated for the previous encoding scheme are freed, and any pending data are lost.
Deflate and Inflate are lossless data compression and decompression algorithms that use a combination of the LZ77 algorithm and Huffman coding. They are widely used in many common file formats, such as zip, gzip, or PNG. Note the StreamCipher object does not handle those formats directly, but only provides the compression and decompression algorithms on which they rely. For example, to extract a file from an archive, you'll have to write your own code to open the archive, check its format, browse its directory, locate the compressed stream into it, and so on.
The iCompression parameter specifies the compression rate, and can take any value from 0 to 9 inclusive. The lowest value means no compression at all (data are passed unchanged to the underlying Source stream), while the highest value means to compress as much as possible. The following table summarizes this:
| Compression Level | Description |
| 0 | No compression. |
| 1 to 3 | The algorithm minimizes insertion into the LZ77 string table. This provides high performance, but poor compression on low entropy data. |
| 4 to 9 | The algorithm maximizes redundancy search. This impacts performances, but better compresses data. |
In most cases, deflating data is a CPU intensive operation, especially if you choose a high level for the iCompression parameter. To avoid bad user experience, it may be advised to display some kind of dialog box while compressing to inform the user that a lengthy operation is running and that the device is not frozen.
Note: this mode only supports write operations. You cannot read data from a StreamCipher object whose scheme was set to Deflate.
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |