util: Add toString and operator<< for util::Digest

Change-Id: Id3695ad1d66dcc93f08085ee42556c71e3eb419c
diff --git a/src/util/digest.hpp b/src/util/digest.hpp
index 39ff811..db9ccc1 100644
--- a/src/util/digest.hpp
+++ b/src/util/digest.hpp
@@ -163,6 +163,14 @@
   static ConstBufferPtr
   computeDigest(const uint8_t* buffer, size_t size);
 
+  /**
+   * @brief Convert digest to std::string
+   *
+   * Note that this method will invoke computeDigest().
+   * Once this method is invoked, the digest is finalized.
+   */
+  std::string
+  toString();
 
 private:
   /**
@@ -180,6 +188,10 @@
   bool m_isFinalized;
 };
 
+template<typename Hash>
+std::ostream&
+operator<<(std::ostream& os, Digest<Hash>& digest);
+
 /**
  * @brief A digest using SHA256 as the hash function.
  */