26 lines
827 B
Python
26 lines
827 B
Python
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
|