import base64 import json import time import uuid from Crypto.Cipher import AES def encrypt_padding(string: str, block_size: int) -> str: length = len(string.encode('utf-8')) add_length = block_size - (length % block_size) return string + (chr(add_length) * add_length) def aes_encrypt(string: str, aes_key: str) -> str: cipher = AES.new(aes_key.encode('utf-8'), AES.MODE_ECB) cipher_text = cipher.encrypt(encrypt_padding(string, AES.block_size).encode('utf-8')) cipher_text = base64.b64encode(cipher_text) return cipher_text.decode() def genRat(url: str,emp:int) -> str: mi = { 't': int(time.time() * 1000), 'w': str(uuid.uuid4()), 'r': url, 'u': emp } return aes_encrypt(json.dumps(mi), '253140fdc9c44b0cb903c387b3e85d64')