mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-05 20:41:34 -07:00
support function
This commit is contained in:
parent
21bae5c73f
commit
630708c3eb
2 changed files with 29 additions and 0 deletions
|
@ -1212,6 +1212,29 @@ void binstr_2_bytes(uint8_t *target, size_t *targetlen, const char *src) {
|
|||
}
|
||||
}
|
||||
|
||||
void binstr_2_u8(char *src, uint8_t n, uint8_t *dest) {
|
||||
|
||||
uint8_t b = 0;
|
||||
// Process binary string
|
||||
for (uint8_t i = 0; i < n; ++i) {
|
||||
b = (b << 1) | (src[i] == '1');
|
||||
}
|
||||
if (dest) {
|
||||
*dest = b;
|
||||
}
|
||||
}
|
||||
|
||||
void binstr_2_u16(char *src, uint8_t n, uint16_t *dest) {
|
||||
uint16_t b = 0;
|
||||
// Process binary string
|
||||
for (uint8_t i = 0; i < n; ++i) {
|
||||
b = (b << 1) | (src[i] == '1');
|
||||
}
|
||||
if (dest) {
|
||||
*dest = b;
|
||||
}
|
||||
}
|
||||
|
||||
void hex_xor(uint8_t *d, const uint8_t *x, int n) {
|
||||
while (n--) {
|
||||
d[n] ^= x[n];
|
||||
|
@ -1611,6 +1634,9 @@ size_t unduplicate(uint8_t *d, size_t n, const uint8_t item_n) {
|
|||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (n == 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int write_index = 0;
|
||||
|
||||
|
|
|
@ -141,6 +141,9 @@ int binstr_2_binarray(uint8_t *target, char *source, int length);
|
|||
void bytes_2_binstr(char *target, const uint8_t *source, size_t sourcelen);
|
||||
void binstr_2_bytes(uint8_t *target, size_t *targetlen, const char *src);
|
||||
|
||||
void binstr_2_u8(char *src, uint8_t n, uint8_t *dest);
|
||||
void binstr_2_u16(char *src, uint8_t n, uint16_t *dest);
|
||||
|
||||
void hex_xor(uint8_t *d, const uint8_t *x, int n);
|
||||
void hex_xor_token(uint8_t *d, const uint8_t *x, int dn, int xn);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue