Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void print_hexdump(unsigned char *data, int data_len, int off)
- {
- int line, offset, m;
- const int digits = ceil(log(data_len / 16.0) / log(16)) + 1;
- for (line = 0; line < data_len; line += 16) {
- printf(" %0*X ", digits, line + off);
- for (m = 0; m <= 1; m++) {
- for (offset = 0; offset < 16; offset++) {
- if (line + offset < data_len)
- switch (m) {
- case 0:
- printf("%02x ", data[line + offset]);
- break;
- case 1:
- if (data[line + offset] >= 0x20 && data[line + offset] <= 0x7E)
- printf("%c", data[line + offset]);
- else
- printf(".");
- break;
- }
- else
- printf(" ");
- if (offset % 8 == 7)
- printf(" ");
- }
- printf(" ");
- }
- printf("\n");
- }
- }
Add Comment
Please, Sign In to add comment