mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-15 01:23:04 -07:00
FIX: 'lua calc of iso15692 crc' - works better now
This commit is contained in:
parent
bd7ac487cd
commit
ccb0cd23f5
1 changed files with 13 additions and 4 deletions
|
@ -280,10 +280,19 @@ static int l_CmdConsole(lua_State *L) {
|
|||
}
|
||||
|
||||
static int l_iso15693_crc(lua_State *L) {
|
||||
size_t size;
|
||||
const char *v = luaL_checklstring(L, 1, &size);
|
||||
// iceman, should be size / 2 ?!?
|
||||
lua_pushunsigned(L, crc( CRC_15693, (uint8_t *) v, size));
|
||||
uint32_t tmp;
|
||||
unsigned char buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
size_t size = 0;
|
||||
const char *data = luaL_checklstring(L, 1, &size);
|
||||
|
||||
for (int i = 0; i < size; i += 2) {
|
||||
sscanf(&data[i], "%02x", &tmp);
|
||||
buf[i / 2] = tmp & 0xFF;
|
||||
}
|
||||
|
||||
size /= 2;
|
||||
compute_crc(CRC_15693, buf, size, &buf[size], &buf[size+1]);
|
||||
lua_pushlstring(L, (const char *)&buf, size+2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue