const char *bin 就进坑了,const unsigned char *bin 可以出坑
std::string bin_to_hex(const char *bin, const size_t len) {
std::string s;
for (size_t k = 0; k < len; k++) {
char buffer[3];
std::snprintf(buffer, sizeof(buffer), "%02x", bin[k]);
s += buffer;
}
return s;
}
--
FROM 114.241.228.*