Add formatting to DESfire data dump (#1784)

Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
Tom Samstag 2022-09-27 10:00:50 -07:00 committed by Aleksandr Kutuzov
parent 5bb7cabea6
commit e6e1e7fe15

View File

@ -209,8 +209,24 @@ void mf_df_cat_file(MifareDesfireFile* file, string_t out) {
uint8_t* data = file->contents;
if(data) {
for(int rec = 0; rec < num; rec++) {
for(int ch = 0; ch < size; ch++) {
string_cat_printf(out, "%02x", data[rec * size + ch]);
string_cat_printf(out, "record %d\n", rec);
for(int ch = 0; ch < size; ch += 4) {
string_cat_printf(out, "%03x|", ch);
for(int i = 0; i < 4; i++) {
if(ch + i < size) {
string_cat_printf(out, "%02x ", data[rec * size + ch + i]);
} else {
string_cat_printf(out, " ");
}
}
for(int i = 0; i < 4 && ch + i < size; i++) {
if(isprint(data[rec * size + ch + i])) {
string_cat_printf(out, "%c", data[rec * size + ch + i]);
} else {
string_cat_printf(out, ".");
}
}
string_cat_printf(out, "\n");
}
string_cat_printf(out, " \n");
}