New Chilkat Crypt Feature: FirstChunk/LastChunk properties

The Chilkat Crypt component now provides the ability to feed the encryption/decryption methods with chunks of data. This allows a large amount of data, or a data stream, to be fed piecemeal for encrypting or decrypting. It applies to all symmetric algorithms currently supported (AES, Blowfish, Twofish, 3DES, RC2, DES, ARC4), and all algorithms supported in the future.

First, a quick synopsis of the encrypt/decrypt methods. Here they are:

Encryption methods ending in "ENC" return the encrypted data as an encoded string. The encoding is determined by the value of the EncodingMode property, which can be "base64″, "hex", "url", "quoted-printable", or "html" (for HTML encoded entities).

Decryption methods ending in "ENC" do the opposite — they expect the input argument to be encrypted data in the form of an encoded string (again, the encoding is specified by the EncodingMode property).

The default value for both FirstChunk and LastChunk is TRUE — meaning that when you call an Encrypt* or Decrypt* method, it is both the first and last chunk (i.e. it’s the entire amount of data to be encrypted or decrypted).

If you wish to feed the data piecemeal, do this:

Set FirstChunk = TRUE, LastChunk = FALSE for the first chunk of data.

For all "middle" chunks (i.e. all chunks except for the final chunk) set FirstChunk = FALSE and LastChunk = FALSE. (Note: We are using TRUE/FALSE in a programming-language independent way.)

For the final chunk, set FirstChunk = FALSE and LastChunk = TRUE

You don’t need to worry about feeding data according to the block size of the encryption algorithm. For example, AES has a block size of 16 bytes. You may feed data in chunks of any size. The Chilkat Crypt component will buffer the data. When the final chunk is passed, the output is padded to the algorithm’s block size according to the PaddingScheme.