FBB::DigestBuf(3bobcat) | Compute Message Digests | FBB::DigestBuf(3bobcat) |
FBB::DigestBuf - Computes Message Digests from information inserted into a std::ostream
#include <bobcat/digestbuf>
Linking option: -lbobcat -lcrypto
FBB::DigestBuf objects are std::streambuf objects that can be used to initialize std::ostream objects with.
The message digest of all information inserted into such an std::ostream is computed.
All the message digests defined by the OpenSSL library that can be selected by name may be used in combination with DigestBuf objects.
The currently supported message digest algorithms are shown by the openssl list -digest-commands. The names of the digest algorithms can be used to select a digest algorithms for the class’s constructor, below.
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
std::streambuf
The copy and move constructors and assignment operators are not available.
All members of std::streambuf are available, as FBB::DigestBuf inherits from this class.
1. create a DigestBuf object
2. use it to create a std::ostream object
3. insert information into the ostream object
4. call the DigestBuf object’s eoi() member or insert the
eoi manipulator into the ostream (see below)
5. obtain/process the hash value from the DigestBuf object.
#include <iostream> #include <ostream> #include <bobcat/digestbuf> using namespace std; using namespace FBB; int main(int argc, char **argv) try {
DigestBuf digestbuf(argc == 1 ? "sha256" : argv[1]);
ostream out(&digestbuf);
string hw("hello world\n");
out << hw << eoi;
cout << ">" << digestbuf << "<" << endl;
digestbuf.reset();
out.write(hw.c_str(), hw.length()) << eoi;
cout << ">" << digestbuf << "<" << endl; } catch(exception const &err) {
cout << err.what() << endl;
return 1; }
bobcat/digestbuf - defines the class interface
bobcat(7), hmacbuf(3bobcat), std::streambuf
None reported
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
This is free software, distributed under the terms of the GNU General Public License (GPL).
Frank B. Brokken (f.b.brokken@rug.nl).
2005-2022 | libbobcat-dev_6.02.02 |