error handling if bad input data in db
This commit is contained in:
parent
a28bedf430
commit
b80f2f8e4d
1 changed files with 7 additions and 4 deletions
|
|
@ -117,11 +117,14 @@ async def api_scane(p, c, request: Request):
|
||||||
# so I try one by one until decrypted uid matches
|
# so I try one by one until decrypted uid matches
|
||||||
for cand in await get_all_cards():
|
for cand in await get_all_cards():
|
||||||
if cand.k1:
|
if cand.k1:
|
||||||
card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(cand.k1))
|
try:
|
||||||
|
card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(cand.k1))
|
||||||
|
|
||||||
if card_uid.hex().upper() == cand.uid:
|
if card_uid.hex().upper() == cand.uid:
|
||||||
card = cand
|
card = cand
|
||||||
break
|
break
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
if card == None:
|
if card == None:
|
||||||
return {"status": "ERROR", "reason": "Unknown card."}
|
return {"status": "ERROR", "reason": "Unknown card."}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue