import base64 import binascii import json import random import requests from Crypto.Cipher import AES from Crypto.PublicKey import RSA from string import ascii_letters, digits
_charset = ascii_letters + digits
def rand_char(num=16): return ''.join(random.choice(_charset) for _ in range(num))
def aes_encrypt(msg, key, iv='0102030405060708'): def padded(msg):
pad = 16 - len(msg) % 16 return msg + pad * chr(pad)
msg = padded(msg)
cryptor = AES.new(key, IV=iv, mode=AES.MODE_CBC)
text = cryptor.encrypt(msg)
text = base64.b64encode(text) return text
def gen_params(d, i):
text = aes_encrypt(d, '0CoJUm6Qyw8W8jud')
text = aes_encrypt(text, i) return text
def rsa_encrypt(msg):
cryptor = RSA.construct((0x00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7,0x10001L))
text = cryptor.encrypt(msg[::-1], '')[0]
text = binascii.b2a_hex(text) return text