mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +00:00
🎨 Update hex_digest for requests
This commit is contained in:
parent
e96da60d0c
commit
cbf23737cd
@ -18,11 +18,11 @@ RECOGNIZE_SERVER = {
|
||||
}
|
||||
|
||||
|
||||
def get_device_id(name: str = None):
|
||||
def get_device_id(name: str = ""):
|
||||
return str(uuid.uuid3(uuid.NAMESPACE_URL, name))
|
||||
|
||||
|
||||
def _hexdigest(text):
|
||||
def hex_digest(text):
|
||||
_md5 = hashlib.md5() # nosec B303
|
||||
_md5.update(text.encode())
|
||||
return _md5.hexdigest()
|
||||
@ -43,13 +43,13 @@ def get_ds(ds_type: str = None, new_ds: bool = False, data: Mapping[str, str] =
|
||||
r = str(random.randint(100001, 200000)) # nosec
|
||||
b = json.dumps(data) if data else ''
|
||||
q = urlencode(params) if params else ''
|
||||
c = _hexdigest(f'salt={salt}&t={t}&r={r}&b={b}&q={q}')
|
||||
c = hex_digest(f'salt={salt}&t={t}&r={r}&b={b}&q={q}')
|
||||
return f'{t},{r},{c}'
|
||||
|
||||
def old():
|
||||
t = str(int(time.time()))
|
||||
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
|
||||
c = _hexdigest(f'salt={salt}&t={t}&r={r}')
|
||||
c = hex_digest(f'salt={salt}&t={t}&r={r}')
|
||||
return f'{t},{r},{c}'
|
||||
|
||||
app_version = '2.36.1'
|
||||
|
@ -7,9 +7,10 @@ from genshin import constants, types
|
||||
from genshin.client import routes
|
||||
from genshin.utility import ds
|
||||
|
||||
from modules.apihelper.helpers import get_ds, get_ua, get_device_id
|
||||
from modules.apihelper.helpers import get_ds, get_ua, get_device_id, hex_digest
|
||||
from utils.patch.methods import patch, patchable
|
||||
|
||||
DEVICE_ID = get_device_id()
|
||||
|
||||
@patch(genshin.client.components.calculator.CalculatorClient) # noqa
|
||||
class CalculatorClient:
|
||||
@ -79,8 +80,13 @@ class BaseClient:
|
||||
"ds": ds.generate_dynamic_secret(),
|
||||
}
|
||||
elif region == types.Region.CHINESE:
|
||||
uid = self.cookie_manager.get_user_id()
|
||||
if uid:
|
||||
device_id = hex_digest(str(uid))
|
||||
else:
|
||||
device_id = DEVICE_ID
|
||||
_app_version, _client_type, _ds = get_ds(new_ds=True, data=data, params=params)
|
||||
ua = get_ua(version=_app_version)
|
||||
ua = get_ua(device="Paimon Build " + device_id[0:5], version=_app_version)
|
||||
headers = {
|
||||
"User-Agent": ua,
|
||||
"X_Requested_With": "com.mihoyo.hoyolab",
|
||||
|
Loading…
Reference in New Issue
Block a user