We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 66e65a2 + 8b2c43f commit a0758abCopy full SHA for a0758ab
pre/bytes/utils.hpp
@@ -66,6 +66,22 @@ namespace pre { namespace bytes {
66
67
return out;
68
}
69
+
70
+ /**
71
+ * \brief Converts any given byte string to a corresponding hexadecimal number in a string.
72
+ * \param hex byte string
73
+ */
74
+ inline std::string to_hexstring(const std::string& hex) {
75
+ std::vector<char> bytes;
76
+ for (unsigned int i = 0; i < hex.length(); i += 2) {
77
+ std::string byteString = hex.substr(i, 2);
78
+ char byte = (char) strtol(byteString.c_str(), NULL, 16);
79
+ bytes.push_back(byte);
80
+ }
81
+ std::string bb(bytes.begin(),bytes.end());
82
+ return bb;
83
84
85
86
/**
87
* \brief Convers the given byte array of the given length to a corresponding binary number in a string.
0 commit comments