provides a digest calculation More...
#include <digest.hpp>
Classes | |
class | Error |
Public Types | |
typedef Hash | HashFunction |
Public Member Functions | |
Digest () | |
Digest (std::istream &is) | |
Create digest of the input stream is . More... | |
void | reset () |
Discard the current state and start a new digest. More... | |
bool | empty () const |
Check if digest is empty. More... | |
ConstBufferPtr | computeDigest () |
Obtain the digest. More... | |
bool | operator== (Digest< Hash > &digest) |
Check if supplied digest equal to this digest. More... | |
bool | operator!= (Digest< Hash > &digest) |
Check if supplied digest is not equal to this digest. More... | |
Digest< Hash > & | operator<< (Digest< Hash > &src) |
Add existing digest to digest calculation. More... | |
Digest< Hash > & | operator<< (const std::string &str) |
Add string to digest calculation. More... | |
Digest< Hash > & | operator<< (const Block &block) |
Add block to digest calculation. More... | |
Digest< Hash > & | operator<< (uint64_t value) |
Add uint64_t value to digest calculation. More... | |
void | update (const uint8_t *buffer, size_t size) |
Add a buffer to digest calculation. More... | |
std::string | toString () |
Convert digest to std::string. More... | |
Static Public Member Functions | |
static ConstBufferPtr | computeDigest (const uint8_t *buffer, size_t size) |
Compute one-time digest. More... | |
Public Attributes | |
Hashable< Hash > | |
provides a digest calculation
Take SHA256 as an example:
Digest<CryptoPP::SHA256> digest; digest.update(buf1, size1); digest.update(buf2, size2); ... ConstBufferPtr result = digest.computeDigest();
Definition at line 47 of file digest.hpp.
typedef Hash ndn::util::Digest< Hash >::HashFunction |
Definition at line 52 of file digest.hpp.
ndn::util::Digest< Hash >::Digest | ( | ) |
Definition at line 30 of file digest.cpp.
Referenced by ndn::util::Digest< Hash >::Error::Error().
|
explicit |
Create digest of the input stream is
.
is | input stream |
Definition at line 36 of file digest.cpp.
void ndn::util::Digest< Hash >::reset | ( | ) |
Discard the current state and start a new digest.
Definition at line 50 of file digest.cpp.
Referenced by ndn::util::Digest< Hash >::Error::Error().
|
inline |
Check if digest is empty.
An empty digest means nothing has been taken into calculation.
Definition at line 85 of file digest.hpp.
References ndn::util::Digest< Hash >::computeDigest(), and ndn::util::Digest< Hash >::operator==().
ConstBufferPtr ndn::util::Digest< Hash >::computeDigest | ( | ) |
Obtain the digest.
Note this digest is finalized once this method is invoked.
Definition at line 73 of file digest.cpp.
Referenced by ndn::util::Digest< Hash >::empty(), ndn::util::Digest< Hash >::operator!=(), ndn::util::Digest< Hash >::operator<<(), and ndn::util::Digest< Hash >::operator==().
bool ndn::util::Digest< Hash >::operator== | ( | Digest< Hash > & | digest | ) |
Check if supplied digest equal to this digest.
Note that this method will invoke computeDigest(). Once this method is invoked, both this digest and the supplied digest are finalized.
Definition at line 81 of file digest.cpp.
References ndn::util::Digest< Hash >::computeDigest().
Referenced by ndn::util::Digest< Hash >::empty().
|
inline |
Check if supplied digest is not equal to this digest.
Note that this method will invoke computeDigest(). Once this method is invoked, both this digest and the supplied digest are finalized.
Definition at line 120 of file digest.hpp.
References ndn::util::Digest< Hash >::computeDigest(), ndn::util::Digest< Hash >::operator<<(), ndn::util::Digest< Hash >::toString(), and ndn::util::Digest< Hash >::update().
Digest< Hash > & ndn::util::Digest< Hash >::operator<< | ( | Digest< Hash > & | src | ) |
Add existing digest to digest calculation.
src | digest to combine with |
The result of this combination is hash (hash (...)) Note that this method will invoke computeDigest(). Once this method is invoked, the supplied digest is fixed.
Definition at line 88 of file digest.cpp.
References ndn::util::Digest< Hash >::computeDigest(), and ndn::util::Digest< Hash >::update().
Referenced by ndn::util::Digest< Hash >::operator!=().
Digest< Hash > & ndn::util::Digest< Hash >::operator<< | ( | const std::string & | str | ) |
Add string to digest calculation.
str | string to put into digest |
Definition at line 98 of file digest.cpp.
References ndn::util::Digest< Hash >::update().
Digest< Hash > & ndn::util::Digest< Hash >::operator<< | ( | const Block & | block | ) |
Add block to digest calculation.
block | to put into digest |
Definition at line 107 of file digest.cpp.
References ndn::Block::size(), ndn::util::Digest< Hash >::update(), and ndn::Block::wire().
Digest< Hash > & ndn::util::Digest< Hash >::operator<< | ( | uint64_t | value | ) |
Add uint64_t value to digest calculation.
value | uint64_t value to put into digest |
Definition at line 116 of file digest.cpp.
References ndn::util::Digest< Hash >::update().
void ndn::util::Digest< Hash >::update | ( | const uint8_t * | buffer, |
size_t | size | ||
) |
Add a buffer to digest calculation.
Update the state of the digest if it is not finalized and mark the digest as InProcess.
buffer | the input buffer |
size | the size of the input buffer. |
Error | if the digest has been finalized. |
Definition at line 125 of file digest.cpp.
Referenced by ndn::util::Digest< Hash >::operator!=(), and ndn::util::Digest< Hash >::operator<<().
|
static |
Compute one-time digest.
buffer | the input buffer |
size | the size of the input buffer. |
Definition at line 138 of file digest.cpp.
std::string ndn::util::Digest< Hash >::toString | ( | ) |
Convert digest to std::string.
Note that this method will invoke computeDigest(). Once this method is invoked, the digest is finalized.
Definition at line 150 of file digest.cpp.
Referenced by ndn::util::Digest< Hash >::operator!=().
ndn::util::Digest< Hash >::Hashable< Hash > |
Definition at line 50 of file digest.hpp.