我尝试在我的机器上同时使用 Python 和 Python 3 运行这段代码,但它有很多错误,例如:
python3 gen.py
输出:
Traceback (most recent call last):
File "/home/kali/Downloads/gen.py", line 1, in <module>
from crypto.Cipher import DES
ModuleNotFoundError: No module named 'crypto'
和:
python gen.py
输出:
Traceback (most recent call last):
File "gen.py", line 1, in <module>
from Crypto.Cipher import DES
ImportError: No module named Crypto.Cipher
from Crypto.Cipher import DES
import binascii
key = open('key').read()
iv = '55531056'
cipher = DES.new(key, DES.MODE_OFB, iv)
plaintext = open('plain.txt').read()
msg = iv + cipher.encrypt(plaintext)
with open('flag.enc', 'w') as f:
f.write(msg)
您似乎缺少名为
crypto
的包裹。
安装它并再次执行您的程序:
pip install pycrypto