Rename uid_hash init param as uid_salt.

uid_h renamed to uid_hash.
This commit is contained in:
Valdur Kana 2022-03-11 19:51:12 +02:00
parent 7cc479f468
commit a9f7638c14
1 changed files with 9 additions and 9 deletions

View File

@ -29,12 +29,12 @@ class DoorController:
api_longpoll, api_longpoll,
api_swipe, api_swipe,
api_key, api_key,
uid_hash): uid_salt):
self.door = door self.door = door
self.api_allowed = api_allowed self.api_allowed = api_allowed
self.api_longpoll = api_longpoll self.api_longpoll = api_longpoll
self.api_swipe = api_swipe self.api_swipe = api_swipe
self.uid_hash = uid_hash self.uid_salt = uid_salt
self.uids = {} self.uids = {}
@ -68,18 +68,18 @@ class DoorController:
self.uids = uids self.uids = uids
def wiegand_callback(self, bits, value): def wiegand_callback(self, bits, value):
uid_h = hash_uid(value, self.uid_hash) uid_hash = hash_uid(value, self.uid_salt)
logging.debug(f"hash {uid_h}") logging.debug(f"hash {uid_hash}")
if uid_h in self.uids: if uid_hash in self.uids:
logging.info(f"Opening door for UID hash trail {uid_h[-10:]}") logging.info(f"Opening door for UID hash trail {uid_hash[-10:]}")
self.wiegand.open_door() self.wiegand.open_door()
success = True success = True
else: else:
logging.info(f"Access card not in allow list, hash trail {uid_h[-10:]}") logging.info(f"Access card not in allow list, hash trail {uid_hash[-10:]}")
success = False success = False
data = { data = {
"uid": value, "uid": value,
"uid_hash": uid_h, "uid_hash": uid_hash,
"door": self.door, "door": self.door,
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) "timestamp": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
} }
@ -131,5 +131,5 @@ if __name__ == "__main__":
api_longpoll=os.environ["KDOORPI_API_LONGPOLL"], api_longpoll=os.environ["KDOORPI_API_LONGPOLL"],
api_swipe=os.environ["KDOORPI_API_SWIPE"], api_swipe=os.environ["KDOORPI_API_SWIPE"],
api_key=os.environ["KDOORPI_API_KEY"], api_key=os.environ["KDOORPI_API_KEY"],
uid_hash=os.environ["KDOORPI_UID_SALT"], uid_salt=os.environ["KDOORPI_UID_SALT"],
) )