CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
hash::MD5 Class Reference

compute MD5 hash More...

#include <md5.h>

Public Types

enum  { BlockSize = 512 / 8 , HashBytes = 16 }
 split into 64 byte blocks (=> 512 bits), hash is 16 bytes long More...

Public Member Functions

 MD5 ()
 same as reset()
std::string operator() (const void *data, size_t numBytes)
 compute MD5 of a memory block
std::string operator() (const std::string &text)
 compute MD5 of a string, excluding final zero
void add (const void *data, size_t numBytes)
 add arbitrary number of bytes
std::string getHash ()
 return latest hash as 32 hex characters
void getHash (unsigned char buffer[HashBytes])
 return latest hash as bytes
void reset ()
 restart

Detailed Description

compute MD5 hash

Usage: MD5 md5; std::string myHash = md5("Hello World"); // std::string std::string myHash2 = md5("How are you", 11); // arbitrary data, 11 bytes

or in a streaming fashion:

MD5 md5;
while (more data available)
  md5.add(pointer to fresh data, number of new bytes);
std::string myHash3 = md5.getHash();

Definition at line 44 of file md5.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

split into 64 byte blocks (=> 512 bits), hash is 16 bytes long

Enumerator
BlockSize 
HashBytes 

Definition at line 48 of file md5.h.

Constructor & Destructor Documentation

◆ MD5()

hash::MD5::MD5 ( )

same as reset()

Member Function Documentation

◆ add()

void hash::MD5::add ( const void * data,
size_t numBytes )

add arbitrary number of bytes

Referenced by cmlabs::Hash_UnitTest().

◆ getHash() [1/2]

std::string hash::MD5::getHash ( )

return latest hash as 32 hex characters

Referenced by cmlabs::Hash_UnitTest().

◆ getHash() [2/2]

void hash::MD5::getHash ( unsigned char buffer[HashBytes])

return latest hash as bytes

References HashBytes.

◆ operator()() [1/2]

std::string hash::MD5::operator() ( const std::string & text)

compute MD5 of a string, excluding final zero

◆ operator()() [2/2]

std::string hash::MD5::operator() ( const void * data,
size_t numBytes )

compute MD5 of a memory block

◆ reset()

void hash::MD5::reset ( )

restart

References BlockSize, and HashBytes.


The documentation for this class was generated from the following file:
  • /home/ubuntu/c/partner/psyclone2/CMSDK/include/hash/md5.h