From ad5cd4c820b094c7cf19b3ab1427f13c98b3af69 Mon Sep 17 00:00:00 2001 From: Elia Marcinkiewicz Date: Wed, 6 Mar 2024 21:00:29 +0100 Subject: [PATCH] document manual hash generation --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 87a762d..0c5d364 100644 --- a/README.md +++ b/README.md @@ -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: