Boost logo

Boost :

From: Chris Fairles (chris.fairles_at_[hidden])
Date: 2007-10-30 07:38:07

Just picked up the crypto lib from the vault (at least the sha1 and
md5 parts). There was one issue with the to_string() member function
of message_digest. It uses snprintf which isn't readily available in
MSVC (vs 2005 at least) so I rewrote it using some bit twiddling:

template<class Context>
std::string message_digest<Context>::to_string() const
  static const char hex_digit[] =
  char buf[context_type::digest_length * 2];

  for (int i = 0; i < context_type::digest_length; ++i) {
        buf[2*i] = hex_digit[((static_cast<const unsigned
        buf[2*i+1] = hex_digit[((static_cast<const unsigned
  return std::string(buf, context_type::digest_length * 2);

This works at least for both vs 2005 and gcc 4.1.1, ymmv


Boost list run by bdawes at, gregod at, cpdaniel at, john at