mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
data hex2bin - talk about brain melt
This commit is contained in:
parent
a34bf3264c
commit
5e963a0746
1 changed files with 21 additions and 0 deletions
|
@ -2421,9 +2421,30 @@ static int Cmdhex2bin(const char *Cmd) {
|
||||||
PrintAndLogEx(FAILED, "Error parsing bytes");
|
PrintAndLogEx(FAILED, "Error parsing bytes");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < dlen; i++) {
|
||||||
|
char x = data[i];
|
||||||
|
if (isxdigit(x) == false) {
|
||||||
|
PrintAndLogEx(ERR, "Non hex digit found");
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "" NOLF);
|
PrintAndLogEx(SUCCESS, "" NOLF);
|
||||||
for (int i = 0; i < dlen; i++) {
|
for (int i = 0; i < dlen; i++) {
|
||||||
char x = data[i];
|
char x = data[i];
|
||||||
|
|
||||||
|
// capitalize
|
||||||
|
if (x >= 'a' && x <= 'f')
|
||||||
|
x -= 32;
|
||||||
|
// convert to numeric value
|
||||||
|
if (x >= '0' && x <= '9')
|
||||||
|
x -= '0';
|
||||||
|
else if (x >= 'A' && x <= 'F')
|
||||||
|
x -= 'A' - 10;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
for (int j = 0 ; j < 4 ; ++j) {
|
for (int j = 0 ; j < 4 ; ++j) {
|
||||||
PrintAndLogEx(NORMAL, "%d" NOLF, (x >> (3 - j)) & 1);
|
PrintAndLogEx(NORMAL, "%d" NOLF, (x >> (3 - j)) & 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue