2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/Pl_MD5.hh>
|
2009-09-26 18:36:04 +00:00
|
|
|
#include <stdexcept>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
Pl_MD5::Pl_MD5(char const* identifier, Pipeline* next) :
|
|
|
|
Pipeline(identifier, next),
|
|
|
|
in_progress(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Pl_MD5::~Pl_MD5()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Pl_MD5::write(unsigned char* buf, int len)
|
|
|
|
{
|
|
|
|
if (! this->in_progress)
|
|
|
|
{
|
|
|
|
this->md5.reset();
|
|
|
|
this->in_progress = true;
|
|
|
|
}
|
|
|
|
this->md5.encodeDataIncrementally((char*) buf, len);
|
|
|
|
this->getNext()->write(buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Pl_MD5::finish()
|
|
|
|
{
|
|
|
|
this->getNext()->finish();
|
|
|
|
this->in_progress = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
Pl_MD5::getHexDigest()
|
|
|
|
{
|
|
|
|
if (this->in_progress)
|
|
|
|
{
|
2009-09-26 18:36:04 +00:00
|
|
|
throw std::logic_error(
|
|
|
|
"digest requested for in-progress MD5 Pipeline");
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
return this->md5.unparse();
|
|
|
|
}
|