
_____________________ Vicente Juan Botet Escribá http://viboes.blogspot.com/ ----- Original Message ----- From: "Scott McMurray" <me22.ca+boost@gmail.com> To: "Boost Developers List" <boost@lists.boost.org> Sent: Thursday, May 06, 2010 2:55 AM Subject: [boost] [rfc] Preliminary Hash Library
I've boostified, cleaned up, and documented the Hash Library I mentioned here about a month ago. Comments, complaints, suggestions, and questions appreciated.
Source code is in the sandbox at http://svn.boost.org/svn/boost/sandbox/hash/
Documentation can be read online at http://www.cs.mcgill.ca/~smcmur/hash/
I was very pleased by how the implementation came together, as templates mean that all the hash algorithms share a substantial portion of their code.
Those details are all hidden from the user, though. Here's an example showing the simplest use of the library:
#include <boost/hash.hpp>
#include <iostream> #include <string>
int main() { std::string s = "Hello World!"; typedef boost::hash::sha2<256> HashPolicy; HashPolicy::digest_type digest = boost::hash::compute_digest<HashPolicy>(s); std::cout << digest << "\n"; }
Thanks, ~ Scott McMurray _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hi, thanks for sharing this library. After reading some pages, I have two question: * Where is documented the MessageDigest concept ? * How compare the optimized and not optimized code (efficiency) showed in the examples? #ifdef BOOST_HASH_NO_OPTIMIZATION return boost::hash::compute_digest<hash_policy>( std::istreambuf_iterator<char>(sbuf), std::istreambuf_iterator<char>() ); #else hash_policy::stream_hash<8>::type hash; for (;;) { boost::array<char, 8*1024> buf; std::streamsize n = sbuf->sgetn(&buf[0], buf.size()); if (!n) break; hash.update_n(buf.begin(), n); } return hash.end_message(); #endif It would be possible to define a template function that provides the optimized code? Best, Vicente