An example of bin2hex
would look like this:
#include <string>
#include <iostream>
std::string bin2hex(const std::string& input)
{
std::string res;
const char hex[] = "0123456789ABCDEF";
for(auto sc : input)
{
unsigned char c = static_cast<unsigned char>(sc);
res += hex[c >> 4];
res += hex[c & 0xf];
}
return res;
}
int main()
{
std::string example = "A string";
std::cout << "bin2hex of " << example << " gives " << bin2hex(example) << std::endl;
}