switched to device-specific WiFI-AP-password

This commit is contained in:
2024-06-06 20:32:13 +02:00
parent 2fea8cfdd6
commit 024a00e1bf
10 changed files with 27 additions and 44 deletions

View File

@@ -1,13 +1,17 @@
import hashlib
SEED = "letmelubeyou"
def djb2_hash(s):
hash = 5381
for c in s:
hash = ((hash << 5) + hash) + ord(c) # hash * 33 + c
return hash & 0xFFFFFFFF # Ensure it's a 32-bit unsigned integer
def generate_password(seed, chip_id):
combined = seed + chip_id
hash_object = hashlib.md5(combined.encode())
return hash_object.hexdigest()[:16] # First 16 characters of the MD5 hash
combined = (seed + chip_id)[:24] # Ensure the combined string is up to 24 characters
hash_value = djb2_hash(combined)
hash_str = f"{hash_value:08X}{hash_value:08X}" # Repeat the hash to ensure at least 16 characters
return hash_str[:32] # Ensure the password is at most 32 characters
if __name__ == "__main__":
SEED = "letmelubeyou"
chip_id = input("Enter the Chip ID in hex (e.g., 1A2B3C4D): ").strip()
chip_id = chip_id.zfill(8).upper() # Ensure it's 8 characters, upper case