MD5.hpp
Go to the documentation of this file.
1 
20 #ifndef MD5_HPP_70TU4G5T
21 #define MD5_HPP_70TU4G5T
22 
23 extern "C" {
24 #include "MD5.h"
25 }
26 
27 #include <string.h>
28 
29 #include <sstream>
30 #include <iomanip>
31 #include "uscxml/Common.h"
32 
33 namespace uscxml {
34 
35  USCXML_API inline std::string md5(const char* data, size_t length) {
36  md5_state_t state;
37  md5_byte_t digest[16];
38 
39  md5_init(&state);
40  md5_append(&state, (const md5_byte_t *)data, length);
41  md5_finish(&state, digest);
42 
43  std::ostringstream ss;
44  ss << std::hex << std::uppercase << std::setfill( '0' );
45  for (size_t i = 0; i < 16; i++) {
46  ss << std::setw( 2 ) << (int)digest[i];
47  }
48 
49  return ss.str();
50  }
51 
52  USCXML_API inline std::string md5(const std::string& data) {
53  return md5(data.data(), data.size());
54  }
55 
56 }
57 
58 
59 #endif /* end of include guard: MD5_HPP_70TU4G5T */
Definition: MD5.h:81
Definition: Breakpoint.cpp:26