blob: 08a937067f73f11bd985a41f7572beca1ebe3efc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#ifndef PL_MD5_HH
#define PL_MD5_HH
// 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/Pipeline.hh>
#include <qpdf/MD5.hh>
class Pl_MD5: public Pipeline
{
public:
QPDF_DLL
Pl_MD5(char const* identifier, Pipeline* next);
QPDF_DLL
virtual ~Pl_MD5();
QPDF_DLL
virtual void write(unsigned char*, size_t);
QPDF_DLL
virtual void finish();
QPDF_DLL
std::string getHexDigest();
// 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.
QPDF_DLL
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.
QPDF_DLL
void persistAcrossFinish(bool);
private:
bool in_progress;
MD5 md5;
bool enabled;
bool persist_across_finish;
};
#endif // PL_MD5_HH
|