|
digestpp 1.0
C++11 header-only message digest library
|
Main class template implementing the public API for hashing. More...
#include <hasher.hpp>
Public Member Functions | |
| template<typename H = HashProvider, typename std::enable_if< std::is_default_constructible< H >::value >::type * = nullptr> | |
| hasher () | |
| Default constructor. | |
| template<typename H = HashProvider, typename std::enable_if<!detail::is_xof< H >::value >::type * = nullptr> | |
| hasher (size_t hashsize) | |
| Constructor with hash size parameter. | |
| template<typename T , typename std::enable_if< detail::is_byte< T >::value >::type * = nullptr> | |
| hasher & | absorb (const T *data, size_t len) |
| Absorbs bytes from a C-style pointer to character buffer. | |
| template<typename T , size_t N, typename std::enable_if< detail::is_byte< T >::value >::type * = nullptr> | |
| hasher & | absorb (const std::array< T, N > &arr) |
| Absorbs bytes from a C++ style array to character buffer. | |
| template<typename T , typename std::enable_if< detail::is_byte< T >::value &&!std::is_same< T, std::string::value_type >::value >::type * = nullptr> | |
| hasher & | absorb (const std::basic_string< T > &str) |
| Absorbs bytes from std::basic_string. | |
| hasher & | absorb (const std::string &str) |
| Absorbs bytes from std::string. | |
| template<typename T , typename std::enable_if< detail::is_byte< T >::value >::type * = nullptr> | |
| hasher & | absorb (std::basic_istream< T > &istr) |
| Absorbs bytes from std::istream. | |
| template<typename IT > | |
| hasher & | absorb (IT begin, IT end) |
| Absorbs bytes from an iterator sequence. | |
| template<typename T , typename H = HashProvider, typename std::enable_if< detail::is_byte< T >::value &&detail::is_xof< H >::value >::type * = nullptr> | |
| void | squeeze (T *buf, size_t len) |
| Squeeze bytes into user-provided preallocated buffer. | |
| template<typename T , size_t N, typename H = HashProvider, typename std::enable_if< detail::is_byte< T >::value &&detail::is_xof< H >::value >::type * = nullptr> | |
| void | squeeze (T(&arr)[N]) |
| Squeeze bytes into user-provided preallocated buffer. | |
| template<typename T , size_t N, typename H = HashProvider, typename std::enable_if< detail::is_byte< T >::value &&detail::is_xof< H >::value >::type * = nullptr> | |
| void | squeeze (std::array< T, N > &arr) |
| Squeeze bytes into user-provided preallocated buffer. | |
| template<typename OI , typename H = HashProvider, typename std::enable_if< detail::is_xof< H >::value >::type * = nullptr> | |
| void | squeeze (size_t len, OI it) |
| Squeeze bytes into an output iterator. | |
| template<typename H = HashProvider, typename std::enable_if< detail::is_xof< H >::value >::type * = nullptr> | |
| std::string | hexsqueeze (size_t len) |
| Squeeze bytes and return them as a hex string. | |
| template<typename T , typename H = HashProvider, typename std::enable_if< detail::is_byte< T >::value &&!detail::is_xof< H >::value >::type * = nullptr> | |
| void | digest (T *buf, size_t len) const |
| Output binary digest into user-provided preallocated buffer. | |
| template<typename OI , typename H = HashProvider, typename std::enable_if<!detail::is_xof< H >::value >::type * = nullptr> | |
| void | digest (OI it) const |
| Write binary digest into an output iterator. | |
| template<typename H = HashProvider, typename std::enable_if<!detail::is_xof< H >::value >::type * = nullptr> | |
| std::string | hexdigest () const |
| Return hex digest of absorbed data. | |
| void | reset (bool resetParameters=false) |
| Reset the hasher state to start new digest computation. | |
Main class template implementing the public API for hashing.
Individual hash functions are defined by typedefs. See digestpp namespace description for description of supported hash functions with usage examples.
| HashProvider | A class implementing the algorithm via traditional init/update/final interface. |
| Mixin | A class template which can be used to inject additional functions to the public API of the hasher. |
|
inline |
Default constructor.
|
inline |
Constructor with hash size parameter.
Supported output sizes for each algorithm are listed in the description of corresponding typedef.
| [in] | hashsize | Desired output digest size (in bits). |
| std::runtime_error | if the requested output size is not supported by the algorithm. |
|
inline |
Absorbs bytes from a C++ style array to character buffer.
| [in] | arr | Array to data to absorb |
|
inline |
Absorbs bytes from std::basic_string.
| [in] | str | String to absorb |
|
inline |
Absorbs bytes from std::string.
| [in] | str | String to absorb |
|
inline |
Absorbs bytes from a C-style pointer to character buffer.
| [in] | data | Pointer to data to absorb |
| [in] | len | Size of data to absorb (in bytes) |
|
inline |
Absorbs bytes from an iterator sequence.
| [in] | begin | Begin iterator |
| [in] | end | End iterator |
|
inline |
Absorbs bytes from std::istream.
| [in] | istr | Stream to absorb |
|
inline |
Write binary digest into an output iterator.
This function does not change the state of the hasher and can be called multiple times, producing the same result. To reset the state and start new digest calculation, use reset function.
| [out] | it | Output iterator to a byte container. |
|
inline |
Output binary digest into user-provided preallocated buffer.
This function does not change the state of the hasher and can be called multiple times, producing the same result. To reset the state and start new digest calculation, use reset function.
| [out] | buf | Buffer to squeeze data to; must be of byte type (char, unsigned char or signed char) |
| [in] | len | Size of the buffer |
| std::runtime_error | if the buffer size is not enough to fit the calculated digest (fixed by the algorithm or specified in the hasher constructor). |
|
inline |
Return hex digest of absorbed data.
This function does not change the state of the hasher and can be called multiple times, producing the same result. To reset the state and start new digest calculation, use reset function.
|
inline |
Squeeze bytes and return them as a hex string.
After each invocation of this function the internal state of the hasher changes so that the next call will generate different (additional) output bytes. To reset the state and start new digest calculation, use reset function.
| [in] | len | Size of data to squeeze (in bytes) |
|
inline |
Reset the hasher state to start new digest computation.
| [in] | resetParameters | if true, also clear optional parameters (personalization, salt, etc) |
|
inline |
Squeeze bytes into an output iterator.
After each invocation of this function the internal state of the hasher changes so that the next call will generate different (additional) output bytes. To reset the state and start new digest calculation, use reset function.
| [in] | len | Size of data to squeeze (in bytes) |
| [out] | it | output iterator to a byte container |
|
inline |
Squeeze bytes into user-provided preallocated buffer.
After each invocation of this function the internal state of the hasher changes so that the next call will generate different (additional) output bytes. To reset the state and start new digest calculation, use reset function.
| [out] | arr | Buffer to squeeze data to; must be of byte type (char, unsigned char or signed char) |
|
inline |
Squeeze bytes into user-provided preallocated buffer.
After each invocation of this function the internal state of the hasher changes so that the next call will generate different (additional) output bytes. To reset the state and start new digest calculation, use reset function.
| [out] | buf | Buffer to squeeze data to; must be of byte type (char, unsigned char or signed char) |
| [in] | len | Size of data to squeeze (in bytes) |
|
inline |
Squeeze bytes into user-provided preallocated buffer.
After each invocation of this function the internal state of the hasher changes so that the next call will generate different (additional) output bytes. To reset the state and start new digest calculation, use reset function.
| [out] | arr | Buffer to squeeze data to; must be of byte type (char, unsigned char or signed char) |