#include <sha.h>
Public Member Functions | |
sha1 (void) | |
Constructor. Constructs a SHA-1 object. | |
void | process_msg (bitset_digit_t const *message, size_t number_of_bits) |
Process a complete message. | |
template<unsigned int n> void | process_msg (bitset< n > const &message, size_t number_of_bits=n) |
Process a complete message. | |
bitset< 160 > | digest (void) const |
The resulting hash value. | |
Protected Member Functions | |
void | reset () |
Reset the state of the SHA-1 object. | |
void | process_block (bitset_digit_t const *block) |
Process the next data block. |
This class allows one to calculate a hash value of a bitset using the Secure Hash Algorithm 1, as described in the FIPS PUB 180-1.
Unlike most implementations, this is a bit oriented implementation and therefore more suitable to calculate hash values of bitsets than to calculate hash values of character strings (like for example a text file).
The correct use is as follows.
libecc::bitset<10> msg("3FF"); // A bit set of 10 ones. libecc::sha1 hash_obj; hash_obj.process_msg(msg); libecc::bitset<160> hash(hash_obj.digest());
|
Constructor. Constructs a SHA-1 object.
|
|
The resulting hash value. This method returns the hash value of the last message that was processed, as a 160 bit bitset. |
|
Process the next data block.
This method will process the next block of data. The argument block should be a pointer to an array of |
|
Process a complete message.
|
|
Process a complete message.
Calculate the hash value of a message of number_of_bits, passed as an array of
The following code would correctly print the hash value of a string of characters.
|
|
Reset the state of the SHA-1 object. This method needs to be called prior to calculating the hash value of a message with sha1::process_block. |