string bytesToHexString(const char* bytes, int len) { string result = ""; string temp = "0123456789ABCDEF"; int index = 0; for (int i = 0; i < len; i++) { index = (bytes[i] >> 4) & 0x0f; result.append(1, temp.at(index)); // Append a character at the end of the string. index = bytes[i] & 0x0f; result.append(1, temp.at(index)); } return result; }