66 std::string
hexDump(
const char* bytes, uint64_t length,
int prefixLength,
bool prefixAtFirstLine) {
67 std::stringstream hexStream;
73 hexStream << std::hex;
75 int currentPrefixLength = prefixAtFirstLine ? prefixLength : 0;
78 for (i = 0; i < length; i++) {
84 hexStream <<
" " << buff << std::endl;
88 hexStream << Color::Code::FG_BLUE;
89 hexStream << std::setw(currentPrefixLength) << std::setfill(
' ') <<
""
90 <<
": " << std::setw(8) << std::setfill(
'0') <<
static_cast<
unsigned int>(i);
91 hexStream << Color::Code::FG_DEFAULT <<
" ";
95 hexStream << Color::Code::FG_GREEN;
96 hexStream <<
" " << std::setw(2) << std::setfill(
'0') <<
static_cast<
unsigned int>(
static_cast<
unsigned char>(bytes[i]));
97 hexStream << Color::Code::FG_DEFAULT;
100 if ((bytes[i] < 0x20) || (bytes[i] > 0x7e)) {
103 buff[i % 16] =
static_cast<uint8_t>(bytes[i]);
105 buff[(i % 16) + 1] =
'\0';
107 currentPrefixLength = prefixLength;
110 hexStream << std::dec;
113 while ((i % 16) != 0) {
119 hexStream <<
" " << buff;
122 return hexStream.str();