31 template<
typename Hash>
37 template<
typename Hash>
39 : m_isInProcess(false)
44 m_buffer = make_shared<Buffer>(m_hash.DigestSize());
46 new HashFilter(m_hash,
47 new ArraySink(m_buffer->get(), m_buffer->size())));
50 template<
typename Hash>
55 m_buffer = make_shared<Buffer>(m_hash.DigestSize());
56 m_isInProcess =
false;
57 m_isFinalized =
false;
60 template<
typename Hash>
68 m_hash.Final(m_buffer->get());
73 template<
typename Hash>
81 template<
typename Hash>
88 if (lhs.size() != rhs.size()) {
93 return CRYPTO_memcmp(lhs.
buf(), rhs.
buf(), lhs.size()) == 0;
96 template<
typename Hash>
101 update(buffer->get(), buffer->size());
106 template<
typename Hash>
110 update(reinterpret_cast<const uint8_t*>(str.c_str()), str.size());
115 template<
typename Hash>
124 template<
typename Hash>
128 update(reinterpret_cast<const uint8_t*>(&value),
sizeof(uint64_t));
133 template<
typename Hash>
139 BOOST_THROW_EXCEPTION(
Error(
"Digest has been already finalized"));
141 m_hash.Update(buffer, size);
143 m_isInProcess =
true;
146 template<
typename Hash>
151 BufferPtr result = make_shared<Buffer>(hash.DigestSize());
152 hash.Update(buffer, size);
153 hash.Final(result->get());
158 template<
typename Hash>
162 std::ostringstream os;
168 template<
typename Hash>
170 operator<<(std::ostream& os, Digest<Hash>& digest)
173 printHex(os, buffer->buf(), buffer->size());
179 class Digest<CryptoPP::SHA256>;
183 operator<<(std::ostream& os, Digest<CryptoPP::SHA256>& digest);
Copyright (c) 2013-2016 Regents of the University of California.
void reset()
Discard the current state and start a new digest calculation.
Copyright (c) 2013-2016 Regents of the University of California.
shared_ptr< Buffer > BufferPtr
Class representing a wire element of NDN-TLV packet format.
void printHex(std::ostream &os, const uint8_t *buffer, size_t length, bool isUpperCase)
Output the hex representation of the bytes in array to the output stream os.
provides a stateful digest calculation
Digest< Hash > & operator<<(Digest< Hash > &src)
Add existing digest to the digest calculation.
void update(const uint8_t *buffer, size_t size)
Add a buffer to the digest calculation.
ConstBufferPtr computeDigest()
Finalize and return the digest based on all previously supplied inputs.
const uint8_t * wire() const
bool operator==(Digest< Hash > &digest)
Check if the supplied digest equals to this digest.
shared_ptr< const Buffer > ConstBufferPtr
Class representing a general-use automatically managed/resized buffer.
std::string toString()
Convert digest to std::string.