#include <sstream>
#include <iomanip>
...
std::string toHex(const std::string &input)
{
std::stringstream ss;
ss.setf(ios::uppercase);
ss << hex;
for (size_t i = 0; i < input.length(); i++)
ss << setw(2) << setfill('0')
<< (unsigned short)(input[i] & 0xff);
return ss.str();
}
No comments:
Post a Comment