1 #include "globals.h" 2 #include "bytes.h" 3 #include "fmt/format.h" 4 hexdump(std::ostream & stream,const Bytes & buffer)5void hexdump(std::ostream& stream, const Bytes& buffer) 6 { 7 size_t pos = 0; 8 9 while (pos < buffer.size()) 10 { 11 stream << fmt::format("{:05x} : ", pos); 12 for (int i=0; i<16; i++) 13 { 14 if ((pos+i) < buffer.size()) 15 stream << fmt::format("{:02x} ", buffer[pos+i]); 16 else 17 stream << "-- "; 18 } 19 stream << " : "; 20 for (int i=0; i<16; i++) 21 { 22 if ((pos+i) >= buffer.size()) 23 break; 24 25 uint8_t c = buffer[pos+i]; 26 stream << (isprint(c) ? (char)c : '.'); 27 } 28 stream << std::endl; 29 30 pos += 16; 31 } 32 } 33 hexdumpForSrp16(std::ostream & stream,const Bytes & buffer)34void hexdumpForSrp16(std::ostream& stream, const Bytes& buffer) 35 { 36 for (uint8_t byte : buffer) 37 stream << fmt::format("{:02x}", byte); 38 stream << std::endl; 39 } 40 41 42