>But in that case you have to know what the output size is ahead of time.
Is there a generic way to know that in advance (i.e. some method call on a StreamTransformationFilter instance) that will return the output size that would be required for a given input size? I couldn't see one in a quick search of the header. Dave -----Original Message----- From: Wei Dai [mailto:[EMAIL PROTECTED] Sent: 05 June 2003 22:48 To: [EMAIL PROTECTED] Subject: Re: Usage of BufferedTransformations and the various filters On Thu, Jun 05, 2003 at 03:24:50PM +0100, David C. Partridge wrote: > CBC_Mode<DES>::Encryption cbcEncryption; > cbcEncryption.SetKeyWithIV(key, cbcEncryption.DefaultKeyLength() > ,iv); > StreamTransformationFilter encryptor(cbcEncryption, > NULL, > StreamTransformationFilter::PKCS_PADDING); > encryptor.Put(plaintext, sizeof(plaintext)); > encryptor.MessageEnd(); > > unsigned int outputLength = encryptor.MaxRetrievable(); > ciphertext = new byte[1 + outputLength]; > encryptor.Get(ciphertext, outputLength); This is fine, but not as efficient as it could be. First you don't need to allocate an extra byte for the ciphertext, since the output is not a zero termininated string. Second, if you attach an ArraySink to the StreamTransformationFilter, you can have the output written directly to the ciphertext byte array, instead of being buffered inside StreamTransformationFilter first. But in that case you have to know what the output size is ahead of time. > Are there any annotated samples (a tutorial if you like) on making effective > use of this stuff to accomplish more complex tasks? Have you already read the FAQ entry? http://www.eskimo.com/~weidai/cgi-bin/fom.cgi?file=29 > PS How do stop the mailing list from copying me on my own posts? I don't think you can.