SHA1.hpp
Go to the documentation of this file.
1 
20 #ifndef SHA1_HPP_XJADWV5G
21 #define SHA1_HPP_XJADWV5G
22 
23 extern "C" {
24 #include "SHA1.h"
25 }
26 
27 #include <string.h>
28 #include <sstream>
29 #include <iomanip>
30 #include "uscxml/Common.h"
31 
32 namespace uscxml {
33  USCXML_API inline std::string sha1(const char* data, size_t length) {
34  SHA1Context sha;
35  SHA1Reset(&sha);
36  SHA1Input(&sha, (const unsigned char*)data, length);
37  if (!SHA1Result(&sha)) {
38  return "";
39  } else {
40  std::ostringstream ss;
41  ss << std::hex << std::uppercase << std::setfill( '0' );
42  for (size_t i = 0; i < 5; i++) {
43  ss << std::setw( 2 ) << sha.Message_Digest[i];
44  }
45 
46  return ss.str();
47  }
48  }
49 
50  USCXML_API inline std::string sha1(const std::string& data) {
51  return sha1(data.data(), data.size());
52  }
53 }
54 
55 #endif /* end of include guard: SHA1_HPP_XJADWV5G */
Definition: Breakpoint.cpp:26
Definition: SHA1.h:62