我有这个应该生成密钥的 Python 代码,但我无法在 Linux 上执行该程序

问题描述 投票:0回答:1

我尝试在我的机器上同时使用 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)
python python-3.x cryptography pycrypto pycryptodome
1个回答
0
投票

您似乎缺少名为

crypto
的包裹。 安装它并再次执行您的程序:

pip install pycrypto
© www.soinside.com 2019 - 2024. All rights reserved.