#include <cel_checksum.h>

Public Member Functions | |
| virtual void | writeSum (Stream *inStream=NULL)=0 |
| virtual bool | verifySum (Stream *inStream=NULL)=0 |
| virtual void | resetSum ()=0 |
| virtual const u8 * | getCurrentSum ()=0 |
| virtual size_t | getSumSize () const =0 |
// Writer sample void writeData(Stream *inStream) { AutoPtr<MD5Stream> md5 = MD5Stream::create(inStream); // write data as if it were the original stream. md5->writeBytes(...); md5->writeBytes(...); md5->writeBytes(...); // save the current MD5 sum md5->writeSum(); } // Reader sample void readData(Stream *inStream) { AutoPtr<MD5Stream> md5 = MD5Stream::create(inStream); // read the data as if it were the original stream. // This should read the bytes exactly identical to the ones // written by writeData function, otherwise the verifySum // fails. md5->readBytes(...); md5->readBytes(...); md5->readBytes(...); // verify the current MD5 sum if(md5->verifySum()) { // The sum is identical } else { // The sum is not identical } }
ChecksumStream defines an interface for the Stream with Checksum feature.
Definition at line 168 of file cel_checksum.h.
| virtual void Celartem::ChecksumStream::writeSum | ( | Stream * | inStream = NULL |
) | [pure virtual] |
This method writes the sum to the specified stream.
| inStream | A stream to write. NULL to write on this stream. |
| virtual bool Celartem::ChecksumStream::verifySum | ( | Stream * | inStream = NULL |
) | [pure virtual] |
This method verifies the sum which is read from the specified stream.
| inStream | A stream to read from. NULL to read from this stream. |
true if the sum read from the specified stream is match to the one of current sum, otherwise false. | virtual void Celartem::ChecksumStream::resetSum | ( | ) | [pure virtual] |
This method resets the current sum and revert to the initial state.
| virtual const u8* Celartem::ChecksumStream::getCurrentSum | ( | ) | [pure virtual] |
This method gets the current sum as the binary block.
| virtual size_t Celartem::ChecksumStream::getSumSize | ( | ) | const [pure virtual] |
This method gets the size of sums in bytes that is generated by the instance. The size of sum is usually a constant; MD5 uses 16, SHA-1 uses 20.