From c56021366fa195f795a977233a34f4466e15ba02 Mon Sep 17 00:00:00 2001 From: smallfawn <101914820+smallfawn@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:31:30 +0800 Subject: [PATCH] Update decode.py --- src/decode.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/decode.py b/src/decode.py index 793e880..9ce0f80 100644 --- a/src/decode.py +++ b/src/decode.py @@ -109,5 +109,18 @@ with open('./input.py', 'r', encoding='utf-8') as file: final_decrypted_data = decrypt_nested(encoded_data) # 输出最终解密结果 # print("最终解密结果:") +def process_data(data): + if isinstance(data, str): + # 如果是字符串,则编码为字节对象 + byte_data = data.encode('utf-8') + elif isinstance(data, bytes): + # 如果已经是字节对象,则直接使用 + byte_data = data + else: + # 如果不是字符串也不是字节对象,抛出异常或做其他处理 + raise TypeError("Expected string or bytes-like object") + return byte_data + + with open("./onput.py", 'wb') as f: - f.write(final_decrypted_data.encode('utf-8')) + f.write(process_data(final_decrypted_data))