有赞推送解密
有赞推送解密
点击查看代码
params = {'message':
['2375i3gee%2F0ip4TMJc1cXMM%2FaP9KF5jMhEzWOOmY6v2OolL6xjg1qPtZxkwRG4Ts3rWfjbKIe53Wku3cjUHvARu4FuHf5%2Fppuo5EWEQwz6Yv8Vs0vk%2FpsrDR85cCNUyxBEY%2F6yHyp7fQLWC0jzMcPdoX2rD8%2FE0lA6MKwKvp5DLGTwhoLlKBZ7hMAyyR%2Ff545ED5sp%2BlmmW5hj%2B3DQ21ukqSuglcpILu7Yt5m028mwnLS%2BcvCiAOK2kUeo4lq2ZCmLqon57uC971llHLfOhEnrSkxvFiU0AEprjtbEsYKKs4WoN%2Be5MdKdiJOO09Y2QOjm9D9lUeFMcXnJqMUWz22SeMtPoJ5k9sLfv1e8fv3sygf0M0H2MJRYdBp9OPclwHt3PKEvcBEV2Eu1Lp6NNOhe3xHALCNnxotT3VqGL2j7%2FhjGbdOFtGyMNW41UdRF95CJHDL%2FRvKZwq6zpzlUf8jg%3D%3D']
}
def aes_decrypt(content, str_key):
def get_key(str_key_data):
arr_b_tmp = str_key_data.encode()
arr_b = bytearray(16)
for i in range(min(len(arr_b_tmp), len(arr_b))):
arr_b[i] = arr_b_tmp[i]
return bytes(arr_b)
skey_spec = get_key(str_key)
cipher = AES.new(skey_spec, AES.MODE_CBC, b'0102030405060708')
original = unpad(cipher.decrypt(content), AES.block_size)
original_string = original.decode('utf-8')
return original_string
token = params.get('message')
message = urllib.parse.unquote(token[0])
bytes_base64 = base64.b64decode(message)
decry_result = aes_decrypt(bytes_base64, ClientSecret)
本文来自博客园,作者:寻月隐君,转载请注明原文链接:https://www.cnblogs.com/QiaoPengjun/p/17654887.html