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 <iostream>
29 #include <sstream>
30 #include <iomanip>
31 #include "uscxml/Common.h"
32 
33 namespace uscxml {
34  USCXML_API inline std::string sha1(const char* data, size_t length) {
35  SHA1Context sha;
36  SHA1Reset(&sha);
37  SHA1Input(&sha, (const unsigned char*)data, length);
38  if (!SHA1Result(&sha)) {
39  return "";
40  } else {
41  std::ostringstream ss;
42  ss << std::hex << std::uppercase << std::setfill( '0' );
43  for (size_t i = 0; i < 5; i++) {
44  ss << std::setw( 2 ) << sha.Message_Digest[i];
45  }
46 
47  return ss.str();
48  }
49  }
50 
51  USCXML_API inline std::string sha1(const std::string& data) {
52  return sha1(data.data(), data.size());
53  }
54 }
55 
56 #endif /* end of include guard: SHA1_HPP_XJADWV5G */
Definition: InterpreterIssue.cpp:33
Definition: SHA1.h:62