[Botan-devel] Converting pipe result to unsigned char*

Jack Lloyd lloyd at randombit.net
Fri Dec 2 12:12:20 EST 2005


If the output is binary, using Pipe's read() functions should work nicely; they
will write the output directly into a provided array of unsigned chars. The
basic idiom is:

Pipe pipe(/* some filters */);
pipe.process_msg(/* blah */);

const u32bit expecting = pipe.remaining();

// byte == Botan's typedef for unsigned char
byte* output = new byte[expecting];

if(pipe.read(output, expecting) != expecting)
   signal_error(); // this should never happen, but just to be safe...

-Jack

On Fri, Dec 02, 2005 at 04:55:57PM +0000, Kang Chung wrote:
> I need to convert the pipe encryption/decryption result to a unsigned char* somehow.
> I've tried the std::string to a unsigned char[], but this does not seem to be a good solution.
> 
> Does anyone have any good ideas? Please?
> 
> /Kang Chung
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://www.randombit.net/mailman/listinfo/botan-devel




More information about the botan-devel mailing list