login about faq

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?

asked Dec 27 '12 at 14:54

Dilip's gravatar image

Dilip
1222

Need to do this in C Win64 - no C++

The goal is to read a file (say 4kb or some such number at a time), file contents are NOT ASCII or Unicode strings - and encrypt the buffer into which the file contents have been read. Presumably the last buffer may be a partial buffer.

Cannot use the file encryption methods since they dont exist on iOS. End goal is to be able to move encrypted file between Windows & iOS devices. So start with a C Win64, get it working, then port to iOS

Please advise

(Dec 28 '12 at 11:51) Dilip

is CkByte_BorrowData the answer?

(Dec 28 '12 at 12:10) Dilip

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[20000];
CkByteData bd;

// Tell the CkByteData to reference the 5000 bytes starting at the middle of the myJpgData buffer. bd.borrowData(&myJpgData[10000],5000);

link

answered Dec 28 '12 at 09:26

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

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

link

answered Dec 28 '12 at 13:43

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×64

Asked: Dec 27 '12 at 14:54

Seen: 1,441 times

Last updated: Dec 28 '12 at 13:43

powered by OSQA