diff options
Diffstat (limited to 'libqpdf/Pl_SHA2.cc')
-rw-r--r-- | libqpdf/Pl_SHA2.cc | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/libqpdf/Pl_SHA2.cc b/libqpdf/Pl_SHA2.cc index 018f411f..84f24d6e 100644 --- a/libqpdf/Pl_SHA2.cc +++ b/libqpdf/Pl_SHA2.cc @@ -2,6 +2,7 @@ #include <stdexcept> #include <cstdio> #include <qpdf/PointerHolder.hh> +#include <qpdf/QUtil.hh> Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) : Pipeline("sha2", next), @@ -150,15 +151,5 @@ Pl_SHA2::getHexDigest() throw std::logic_error( "digest requested for in-progress SHA2 Pipeline"); } - std::string raw = getRawDigest(); - size_t raw_size = raw.length(); - size_t hex_size = 1 + (2 * raw_size); - PointerHolder<char> bufp(true, new char[hex_size]); - char* buf = bufp.getPointer(); - buf[hex_size - 1] = '\0'; - for (unsigned int i = 0; i < raw_size; ++i) - { - std::sprintf(buf + i * 2, "%02x", (unsigned char)raw[i]); - } - return buf; + return QUtil::hex_encode(getRawDigest()); } |