2018-08-12 18:07:22 +00:00
|
|
|
#ifndef PL_MD5_HH
|
|
|
|
#define PL_MD5_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
// This pipeline sends its output to its successor unmodified. After calling finish, the MD5
|
|
|
|
// checksum of the data that passed through the pipeline is available.
|
|
|
|
|
|
|
|
// This pipeline is reusable; i.e., it is safe to call write() after calling finish(). The first
|
|
|
|
// call to write() after a call to finish() initializes a new MD5 object.
|
|
|
|
|
|
|
|
#include <qpdf/MD5.hh>
|
|
|
|
#include <qpdf/Pipeline.hh>
|
|
|
|
|
2009-10-21 00:27:24 +00:00
|
|
|
class Pl_MD5: public Pipeline
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Pl_MD5(char const* identifier, Pipeline* next);
|
2023-06-01 14:21:32 +00:00
|
|
|
~Pl_MD5() override = default;
|
|
|
|
void write(unsigned char const*, size_t) override;
|
|
|
|
void finish() override;
|
2008-04-29 12:55:25 +00:00
|
|
|
std::string getHexDigest();
|
2015-10-25 15:09:25 +00:00
|
|
|
// Enable/disable. Disabling the pipeline causes it to become a pass-through. This makes it
|
|
|
|
// possible to stick an MD5 pipeline in a pipeline when it may or may not be required. Disabling
|
|
|
|
// it avoids incurring the runtime overhead of doing needless digest computation.
|
|
|
|
void enable(bool enabled);
|
|
|
|
// If persistAcrossFinish is called, calls to finish do not finalize the underlying md5 object.
|
|
|
|
// In this case, the object is not finalized until getHexDigest() is called.
|
|
|
|
void persistAcrossFinish(bool);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool in_progress;
|
|
|
|
MD5 md5;
|
2015-10-25 15:09:25 +00:00
|
|
|
bool enabled;
|
|
|
|
bool persist_across_finish;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // PL_MD5_HH
|