The Chilkat examples show how to encrypt a text string. I want to encrypt data that is not ascII or any kind of text. How do I do that?
EncryptBytes seems to be the correct API to use, but what puzzles me is how do I specify the number of bytes in the array?
I want to encrypt a jpg picture, so do I have to encrypt the picture 16 bytes at a time if the encryption algo I choose has a block size of 16?
The block size of an encryption algorithm does not mean you need to feed the Chilkat API that many bytes at a time. You may pass any number of bytes to the EncryptBytes method, regardless of encryption algorithm or the algorithm's block size.
I'll assume you are asking about the C++ method:
bool CkCrypt2::EncryptBytes(const CkByteData &inBytes, CkByteData &outBytes)You must pass the bytes in a CkByteData object. If you have a pointer to bytes you wish to encrypt, but don't wish to copy them into a CkByteData object, you can use CkByteData::borrowData to tell the CkByteData to use your bytes directly. For example:
unsigned char myJpgData; CkByteData bd;
// Tell the CkByteData to reference the 5000 bytes starting at the middle of the myJpgData buffer. bd.borrowData(&myJpgData,5000);
You would use the FirstChunk/LastChunk properties. See the online reference documentation. Also, see this: FirstChunk/LastChunk properties.
I realize C# is not your programming language, but see this C# example for a conceptual understanding of how it works: http://www.example-code.com/csharp/aes_dataStream.asp