Skip to content

Instantly share code, notes, and snippets.

@csrutil
Created November 8, 2023 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csrutil/8cbfd2002ad812103fff370a198f3a04 to your computer and use it in GitHub Desktop.
Save csrutil/8cbfd2002ad812103fff370a198f3a04 to your computer and use it in GitHub Desktop.
## https://www.zhihu.com/question/424089478
import hashlib
def getpwd(uid):
uid = bytearray.fromhex(uid)
h = bytearray.fromhex(hashlib.sha1(uid).hexdigest())
pwd = ""
pwd += "%02X" % h[h[0] % 20]
pwd += "%02X" % h[(h[0] + 5) % 20]
pwd += "%02X" % h[(h[0] + 13) % 20]
pwd += "%02X" % h[(h[0] + 17) % 20]
return pwd
print(getpwd("这里输入14位卡号"))
# hf mfu wrbl b 8 d 00000000 k 这里输8位密码
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment