对于这个问题,我得到了一个加密的文本文件,并被要求找到密钥,然后将文件解密为 .txt.gz 文件。
到目前为止,我知道我应该使用的密码是一种替换密码。我得到了用于加密消息的代码,我知道我需要 XOR Rotation 才能找到密钥并破译消息。
这是我在获得密钥时开发的代码
import sys
import gzip
with open("juliaplaintext.txt.gz.enc", "rb") as f:
data = f.read()
k = data.decode("utf-8")
i =0
key = "IbSeMGjyepOr" * 10000
rotated = b""
s = open("juliaplaintext.txt.gz", "wb")
for ch0, ch1 in zip(k, key):
eb = chr(ord(ch0) ^ ord(ch1))
rotated += bytes(ord(eb) >> 7 & 0xff | ord(eb) << 7)
s.write(rotated)
s.close()
我对 python 很陌生,当我没有得到密钥时,我不确定如何创建解码程序。非常感谢任何帮助。