Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

October 20, 2007

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:

EncryptBytes
EncryptBytesENC
EncryptString
EncryptStringENC
	
DecryptBytes
DecryptBytesENC
DecryptString
DecryptStringENC
  1. 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).
  2. 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).
  3. EncryptString/EncryptStringENC expect string input
  4. EncryptBytes/EncryptBytesENC expect binary (byte array) input.
  5. DecryptString/DecryptStringENC return decrypted strings.
  6. 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:

  1. Set FirstChunk = TRUE, LastChunk = FALSE for the first chunk of data.
  2. 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.)
  3. 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.


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.