CMS 3D CMS Logo

Public Member Functions | Public Attributes

cms::MD5Result Struct Reference

#include <Digest.h>

List of all members.

Public Member Functions

std::string compactForm () const
void fromHexifiedString (std::string const &s)
bool isValid () const
 MD5Result ()
std::string toString () const

Public Attributes

unsigned char bytes [16]

Detailed Description

Definition at line 13 of file Digest.h.


Constructor & Destructor Documentation

cms::MD5Result::MD5Result ( )

Definition at line 64 of file Digest.cc.

References cms::set_to_default().

  {
    set_to_default(*this);
  }

Member Function Documentation

std::string cms::MD5Result::compactForm ( ) const

Definition at line 102 of file Digest.cc.

References bytes, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by edm::hash_detail::fixup_(), and edm::detail::InvalidHash().

  {
    // This is somewhat dangerous, because the conversion of 'unsigned
    // char' to 'char' may be undefined if 'char' is a signed type
    // (4.7p3 in the Standard).
    const char* p = reinterpret_cast<const char*>(&bytes[0]);
    return std::string(p, p+sizeof(bytes));
  }
void cms::MD5Result::fromHexifiedString ( std::string const &  s)

Definition at line 111 of file Digest.cc.

References bytes, Exception, i, edm::errors::LogicError, and cms::set_to_default().

Referenced by edm::hash_detail::fixup_().

  {
    switch (hexy.size())
      {
      case 0:
        {
          set_to_default(*this);
        }
        break;
      case 32:
        {
          std::string::const_iterator it = hexy.begin();
          for (size_t i = 0; i != 16; ++i)
            {
              // first nybble
              bytes[i] = ( unhexify(*it++) << 4 );
              // second nybble
              bytes[i] += ( unhexify(*it++) );
            }
        }
        break;
      default:
        {
          // Not really sure of what sort of exception to throw...
          throw edm::Exception(edm::errors::LogicError)
            << "String of illegal length: "
            << hexy.size()
            << " given to MD5Result::fromHexifiedString";         
        }
      }
  }
bool cms::MD5Result::isValid ( void  ) const

Definition at line 143 of file Digest.cc.

  {
    return (*this != invalidResult());
  }
std::string cms::MD5Result::toString ( ) const

Definition at line 87 of file Digest.cc.

References bytes, i, AlCaHLTBitMon_ParallelJobs::p, and cms::s_hexValues.

Referenced by dumpInitHeader(), cms::operator<<(), edm::hash_detail::print_(), edm::hash_detail::toDigest_(), and edm::hash_detail::toString_().

  {
    char buf[16*2];
    char* pBuf=buf;
    for(unsigned int i=0; i<sizeof(bytes);++i){
      const char* p = s_hexValues+2*bytes[i];
      *pBuf = *p;
      ++pBuf;
      ++p;
      *pBuf=*p;
      ++pBuf;
    }
    return std::string(buf, sizeof(buf));
  }

Member Data Documentation

unsigned char cms::MD5Result::bytes[16]