junhoyeo / threads-py

Unofficial, Reverse-Engineered Python client for Meta's Threads.
https://github.com/junhoyeo/threads-api
MIT License
65 stars 14 forks source link

Update DEFAULT_DEVICE_ID generation method #28

Closed drunkleen closed 1 year ago

drunkleen commented 1 year ago

Description:

This pull request updates the method for generating the DEFAULT_DEVICE_ID in the codebase. The previous method used a random number, while the new method utilizes the SHA256 hash of the current timestamp. This change provides a more secure and unique identifier for simulating Android devices, and it reduces the block chance.

Changes Made:

Code Changes:

-import random
- DEFAULT_DEVICE_ID = f"android-{random.randint(0, 1e24):x}"

+ import hashlib
+ import time
+ DEFAULT_DEVICE_ID = 'android-%s' % hashlib.sha256(str(time.time()).encode()).hexdigest()[:16]

Please review and merge this pull request if you find it more officiant. Thank you!