document manual hash generation

meow
Elia Marcinkiewicz 2024-03-06 21:00:29 +01:00
parent b3fd037cd9
commit ad5cd4c820
1 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,22 @@ PN532: No response from PN532!
$
```
## scanning new cards with a phone app
get a phone with nfc and the "nfc tools" app installed, scan card, look for "serial number", get first four bytes of that, use following code:
```
# assumes card serial number 0x13121337 and pin 2137
import hashlib
def generate_hash(card_uid, pin):
card_uid = bytes(reversed(card_uid[:4])).hex()
s = "{:08x}:{}".format(int(pin), card_uid)
hash=hashlib.sha256(s.encode('ascii')).digest().hex()
return hash
generate_hash([0x13,0x12,0x13,0x37],bytearray(source=[ord('2'),ord('1'),ord('3'),ord('7')]))
```
## syncing data from LDAP
big TODO; currently, you need to: