I think you just found a new bug, which can cause an access violation in ChannelSwitch when you have only one route on the channel. Please work around this by attaching HashFilter directly to FileSource instead of through a ChannelSwitch, or use a BitBucket on the second route.
On Thu, Jul 17, 2003 at 05:06:02PM -0400, [EMAIL PROTECTED] wrote: > I'm not sure how I missed that originally, but it worked perfectly, thank > you. I have one other question, this time regarding a program crash I'm > experiencing. The following code is taken directly from test.cpp in 5.1 > (StringSink in place of FileSink, but both product the same error): > > char filename[]="C:\\netstat.cab"; > MD5 md5; > HashFilter md5Filter(md5, new HexEncoder); > SHA sha; > HashFilter shaFilter(sha, new HexEncoder); > ChannelSwitch *channelSwitch; > FileSource file(filename, false, channelSwitch = new ChannelSwitch); > channelSwitch->AddDefaultRoute(md5Filter); > channelSwitch->AddDefaultRoute(shaFilter); > file.PumpAll(); > std::string test; > StringSink sink(test); > cout << "\nMD5: "; > md5Filter.TransferTo(sink); > cout << "\nSHA-1: "; > shaFilter.TransferTo(sink); > *-----------* > this code functions properly, outputting both hash values for the file...the > problem occurs when i truncate the code to handling a single hash: > > char filename[]="C:\\netstat.cab"; > MD5 md5; > HashFilter md5Filter(md5, new HexEncoder); > ChannelSwitch *channelSwitch; > FileSource file(filename, false, channelSwitch = new ChannelSwitch); > channelSwitch->AddDefaultRoute(md5Filter); > file.PumpAll(); > std::string test; > StringSink sink(test); > cout << "\nMD5: "; > md5Filter.TransferTo(sink); > *-----------* > This code throws a System.NullReference exception...as you can see, it is > the same code, merely using a single hash, even though this hash calculates > correctly when two or more are calculated at once. > > > ----- Original Message ----- > From: "Pat Deegan" <[EMAIL PROTECTED]> > To: "CryptoPP" <[EMAIL PROTECTED]> > Sent: Thursday, July 17, 2003 3:57 PM > Subject: Re: Retrieving Hashes for GUI > > > Hello, > > On Thu, 2003-07-17 at 13:27, [EMAIL PROTECTED] wrote: > > For the purposes of my project, I need some simple way to retreive the > > hash internally. ie if I have the file name, I want to be able to > > plug it into the cryptlib, and have the hash (or equivalent byte > > values) return to my interface functions, not outputted directly. > > Can't you just replace your FileSink > (http://cryptopp.sourceforge.net/docs/ref5/class_file_sink.html) with a > StringSink (which is just a > typedef StringSinkTemplate<std::string> StringSink, > http://cryptopp.sourceforge.net/docs/ref5/class_string_sink_template.html) > and use the contents of the std::string in your code? > > Regards, > -- > Pat Deegan, > http://www.psychogenic.com/ > PGP: http://www.keyserver.net 0x03F86A50
