Last active
June 3, 2023 06:40
-
-
Save SebDominguez/63bc2e07e845ccade3f8508658e4d43f to your computer and use it in GitHub Desktop.
[Xiaomi Smart Air Purifier Filter PWD calculator] Calculate the password using a given UID #xiaomi #airFilter
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 sys | |
import hashlib | |
# Usage: pwd.py 04A03CAA1E7080 | |
# credit: https://github.com/Flamingo-tech/xiaomi-air-purifier-reverse-engineering | |
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 | |
# assert getpwd("04A03CAA1E7080") == "CD91AFCC" | |
# assert getpwd("04112233445566") == "EC9805C8" | |
def main(): | |
print("PWD:", getpwd(sys.argv[1])) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment