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:
EncryptBytes
EncryptBytesENC
EncryptString
EncryptStringENC
DecryptBytes
DecryptBytesENC
DecryptString
DecryptStringENC
- 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).
- EncryptString/EncryptStringENC expect string input
- EncryptBytes/EncryptBytesENC expect binary (byte array) input.
- DecryptString/DecryptStringENC return decrypted strings.
- DecryptBytes/DecryptBytesENC return decrypted binary data (byte arrays).
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.
Here are some examples:
ASP: Encrypting/decrypting a data stream.
C#: Encrypting/decrypting a data stream.
Delphi: Encrypting/decrypting a data stream.
Visual FoxPro: Encrypting/decrypting a data stream.
Java: Encrypting/decrypting a data stream.
Perl: Encrypting/decrypting a data stream.
Python: Encrypting/decrypting a data stream.
Ruby: Encrypting/decrypting a data stream.
VB.NET: Encrypting/decrypting a data stream.
Visual Basic: Encrypting/decrypting a data stream.
VBScript: Encrypting/decrypting a data stream.