Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
variant_topic_tools::MD5Sum Class Reference

MD5 sum computation algorithm. More...

#include <MD5Sum.h>

Public Types

typedef boost::array< uint32_t, 4 > Digest
 Definition of the MD5 sum digest type. More...
 

Public Member Functions

void clear ()
 Clear the MD5 sum. More...
 
Digest getDigest () const
 Retrieve the MD5 sum's digest. More...
 
size_t getNumDigestedBits () const
 Retrieve the MD5 sum's number of digested bits. More...
 
 MD5Sum (const std::string &text=std::string())
 Default constructor. More...
 
 MD5Sum (const MD5Sum &src)
 Copy constructor. More...
 
MD5Sumoperator<< (const std::string &text)
 Stream operator for updating the MD5 sum. More...
 
std::string toString () const
 Convert the MD5 sum to a hexadecimal format string. More...
 
void update (const std::string &text)
 Update the MD5 sum using the given string. More...
 
void write (std::ostream &stream) const
 Write the MD5 sum to a stream. More...
 
 ~MD5Sum ()
 Destructor. More...
 

Protected Types

typedef boost::array< uint32_t, 16 > Block
 Definition of the MD5 sum block type. More...
 
typedef boost::array< uint32_t, 2 > Size
 Definition of the MD5 sum size type. More...
 

Protected Member Functions

void update (const uint8_t *bytes, size_t numBytes)
 Update the MD5 sum using the given array of bytes. More...
 

Static Protected Member Functions

static void finalize (Digest &digest, Size &numDigestedBits, Block &buffer)
 Compute the finalized digest. More...
 
static uint32_t rotateLeft (uint32_t value, size_t numBits)
 Perform bit rotation on a digest element. More...
 
static void transform (const Block &block, Digest &digest)
 Transform a block. More...
 
static void update (Digest &digest, Size &numDigestedBits, Block &buffer, const uint8_t *bytes, size_t numBytes)
 Update a digest and its context. More...
 

Protected Attributes

Block buffer
 The buffered bytes which did not fit into the last block. More...
 
Digest digest
 The current digest. More...
 
Size numDigestedBits
 The number of digested bits. More...
 

Static Protected Attributes

static const boost::array< uint32_t, 64 > constants
 Constants according to the MD5 algorithm. More...
 
static const Digest initialDigest
 Initial digest. More...
 
static const boost::array< uint32_t, 64 > numBitRotations
 Number of bit rotations per round according to the MD5 algorithm. More...
 
static const Block padding
 Padding required to fill the last MD5 block for finalization. More...
 

Detailed Description

MD5 sum computation algorithm.

This class implements the Message-Digest Algorithm 5 for computing the MD5 sum of a string.

Definition at line 36 of file MD5Sum.h.

Member Typedef Documentation

typedef boost::array<uint32_t, 16> variant_topic_tools::MD5Sum::Block
protected

Definition of the MD5 sum block type.

Definition at line 89 of file MD5Sum.h.

typedef boost::array<uint32_t, 4> variant_topic_tools::MD5Sum::Digest

Definition of the MD5 sum digest type.

Definition at line 40 of file MD5Sum.h.

typedef boost::array<uint32_t, 2> variant_topic_tools::MD5Sum::Size
protected

Definition of the MD5 sum size type.

Definition at line 85 of file MD5Sum.h.

Constructor & Destructor Documentation

variant_topic_tools::MD5Sum::MD5Sum ( const std::string &  text = std::string())

Default constructor.

Definition at line 68 of file MD5Sum.cpp.

variant_topic_tools::MD5Sum::MD5Sum ( const MD5Sum src)

Copy constructor.

Definition at line 73 of file MD5Sum.cpp.

variant_topic_tools::MD5Sum::~MD5Sum ( )

Destructor.

Definition at line 79 of file MD5Sum.cpp.

Member Function Documentation

void variant_topic_tools::MD5Sum::clear ( )

Clear the MD5 sum.

Definition at line 117 of file MD5Sum.cpp.

void variant_topic_tools::MD5Sum::finalize ( Digest digest,
Size numDigestedBits,
Block buffer 
)
staticprotected

Compute the finalized digest.

Definition at line 217 of file MD5Sum.cpp.

MD5Sum::Digest variant_topic_tools::MD5Sum::getDigest ( ) const

Retrieve the MD5 sum's digest.

Definition at line 94 of file MD5Sum.cpp.

size_t variant_topic_tools::MD5Sum::getNumDigestedBits ( ) const

Retrieve the MD5 sum's number of digested bits.

Definition at line 86 of file MD5Sum.cpp.

MD5Sum & variant_topic_tools::MD5Sum::operator<< ( const std::string &  text)

Stream operator for updating the MD5 sum.

Definition at line 232 of file MD5Sum.cpp.

uint32_t variant_topic_tools::MD5Sum::rotateLeft ( uint32_t  value,
size_t  numBits 
)
staticprotected

Perform bit rotation on a digest element.

Definition at line 181 of file MD5Sum.cpp.

std::string variant_topic_tools::MD5Sum::toString ( ) const

Convert the MD5 sum to a hexadecimal format string.

Definition at line 128 of file MD5Sum.cpp.

void variant_topic_tools::MD5Sum::transform ( const Block block,
Digest digest 
)
staticprotected

Transform a block.

Definition at line 142 of file MD5Sum.cpp.

void variant_topic_tools::MD5Sum::update ( const std::string &  text)

Update the MD5 sum using the given string.

Definition at line 108 of file MD5Sum.cpp.

void variant_topic_tools::MD5Sum::update ( const uint8_t *  bytes,
size_t  numBytes 
)
protected

Update the MD5 sum using the given array of bytes.

Definition at line 113 of file MD5Sum.cpp.

void variant_topic_tools::MD5Sum::update ( Digest digest,
Size numDigestedBits,
Block buffer,
const uint8_t *  bytes,
size_t  numBytes 
)
staticprotected

Update a digest and its context.

Definition at line 185 of file MD5Sum.cpp.

void variant_topic_tools::MD5Sum::write ( std::ostream &  stream) const

Write the MD5 sum to a stream.

Definition at line 124 of file MD5Sum.cpp.

Member Data Documentation

Block variant_topic_tools::MD5Sum::buffer
protected

The buffered bytes which did not fit into the last block.

Definition at line 118 of file MD5Sum.h.

const boost::array< uint32_t, 64 > variant_topic_tools::MD5Sum::constants
staticprotected
Initial value:
= {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
}

Constants according to the MD5 algorithm.

Definition at line 102 of file MD5Sum.h.

Digest variant_topic_tools::MD5Sum::digest
protected

The current digest.

Definition at line 110 of file MD5Sum.h.

const MD5Sum::Digest variant_topic_tools::MD5Sum::initialDigest
staticprotected
Initial value:
= {
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476
}

Initial digest.

Definition at line 93 of file MD5Sum.h.

const boost::array< uint32_t, 64 > variant_topic_tools::MD5Sum::numBitRotations
staticprotected
Initial value:
= {
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
}

Number of bit rotations per round according to the MD5 algorithm.

Definition at line 98 of file MD5Sum.h.

Size variant_topic_tools::MD5Sum::numDigestedBits
protected

The number of digested bits.

Definition at line 114 of file MD5Sum.h.

const MD5Sum::Block variant_topic_tools::MD5Sum::padding
staticprotected
Initial value:
= {
0x00000080, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000
}

Padding required to fill the last MD5 block for finalization.

Definition at line 106 of file MD5Sum.h.


The documentation for this class was generated from the following files:


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:50