|
楼主 |
发表于 2024-10-16 20:41:25
|
显示全部楼层
重庆市重庆市
python 的流程就是 字符串转换成16进制字符串 然后用GZIP 压缩 下面的压缩代码
# 使用gzip进行压缩
output = io.BytesIO()
with gzip.GzipFile(fileobj=output, mode='wb') as f:
f.write(source_data)
compressed_data = output.getvalue()
# 将压缩后的数据转换为16进制字符串
compressed_data_hex = binascii.hexlify(compressed_data).decode('utf-8').upper()
compressed_data_hex = '1F8B0800000000000013' + compressed_data_hex[20:]
compressed_data_hex =base64_encode( compressed_data_hex)
return compressed_data_hex
补充内容 (2024-10-16 20:42):
def base64_encode(hex_data):
# print("base64_encode: " + str(hex_data))
if type(hex_data) != str or hex_data == "":
return ""
temp = base64.b64encode(bytes.fromhex(hex_data)).de...
补充内容 (2024-10-16 20:44):
上面缺的
temp = base64.b64encode(bytes.fromhex(hex_data)).decode();
return temp |
|