Skip to content

Commit

Permalink
Allow 4-6 bytes for raw UID binding
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Feb 5, 2024
1 parent 8ba1875 commit 7be8c68
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/python/binary_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def generateUID(phrase):
int(item) if item.isdigit() else -1
for item in phrase.split(',')
]
if len(uid) == 6 and all(ele >= 0 and ele < 256 for ele in uid):
if (4 <= len(uid) <= 6) and all(ele >= 0 and ele < 256 for ele in uid):
# Extend the UID to 6 bytes, as only 4 are needed to bind
uid = [0] * (6 - len(uid)) + uid
uid = bytes(uid)
else:
uid = hashlib.md5(("-DMY_BINDING_PHRASE=\""+phrase+"\"").encode()).digest()[0:6]
Expand Down

0 comments on commit 7be8c68

Please sign in to comment.