Look up Sink in the online API reference, then you'll see all of the
classes that inherit from Sink, such as StringSink or ArraySink.
On Thu, May 01, 2003 at 01:33:24PM +1000, Matthew Smith wrote:
> Hello,
>
> I need to hash some data (char *) and would like to get the hash back as a
> char *, so far I've come up with (based on the example with the source):
>
> void md5Data(const char *data)
> {
> MD5 md5;
> HashFilter md5Filter(md5);
> auto_ptr<ChannelSwitch> channelSwitch(new ChannelSwitch);
> channelSwitch->AddDefaultRoute(md5Filter);
> StringSource(data, true, channelSwitch.release());
>
> HexEncoder encoder(new FileSink(cout), false);
> cout << "\nMD5: ";
> md5Filter.TransferTo(encoder);
> cout << "\n";
> }
>
> Now, my (limited) understanding of crypto++ is this:
>
> To get the data as a string (rather then stout), I would need to implement a
> class that inherits from Sink, then get the data out of it myself??
>
> I would think that this sort of thing is quite common, is there a better way
> of doing it, or something in the lib I am missing???
>
> Cheers
>
> Matt Smith