柚子快报激活码778899分享:字节转十六进制字符串

http://www.51969.com/

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;

}

柚子快报激活码778899分享:字节转十六进制字符串

http://www.51969.com/

查看原文