Skip to content

Commit

Permalink
Add formatting to DESfire data dump (#1784)
Browse files Browse the repository at this point in the history
Co-authored-by: gornekich <[email protected]>
  • Loading branch information
2 people authored and skotopes committed Sep 27, 2022
1 parent 5bb7cab commit e6e1e7f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/nfc/protocols/mifare_desfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit e6e1e7f

Please sign in to comment.