Created
September 7, 2023 10:53
-
-
Save GrayXu/bba6cb7b2595d22a6fafdec0ef68c795 to your computer and use it in GitHub Desktop.
num2uid.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
num = 1111111111 # only for test | |
reverted = struct.pack('>L', num) | |
asChar = list(reverted) | |
result = asChar[0] ^ asChar[1] ^ asChar[2] ^ asChar[3] | |
uidr = hex(num)[2:] | |
assert(len(uidr)==8) | |
uid = uidr[6:8]+uidr[4:6]+uidr[2:4]+uidr[0:2] | |
valid = hex(result)[2:] | |
print(uid, valid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment