This commit is contained in:
Naruse
2025-04-15 19:36:05 +08:00
parent dd51fb491d
commit ec8972d5d6
121 changed files with 30598 additions and 0 deletions

25
utils/crypto.py Normal file
View File

@@ -0,0 +1,25 @@
import os
import hashlib
import base64
from datetime import datetime
class Crypto:
@staticmethod
def create_session_key(account_uid: str) -> str:
random_bytes = os.urandom(64)
temp = f"{account_uid}.{datetime.now().timestamp()}.{random_bytes.hex()}"
try:
hash_bytes = hashlib.sha512(temp.encode('utf-8')).digest()
return base64.b64encode(hash_bytes).decode('utf-8')
except Exception as e:
hash_bytes = hashlib.sha512(temp.encode('utf-8')).digest()
return base64.b64encode(hash_bytes).decode('utf-8')
def generate_dispatch_token(uid) -> str:
dispatch_token = Crypto.create_session_key(uid)
return dispatch_token
def generate_combo_token(uid) -> str:
dispatch_token = Crypto.create_session_key(uid)
return dispatch_token