【问题标题】:i have this python code that is supposed to generate a key and i cant execute the program on linux我有这个应该生成密钥的python代码,我无法在linux上执行程序
【发布时间】:2022-01-16 17:16:45
【问题描述】:

我尝试在我的机器上同时使用 python 和 python3 运行这段代码,但它有很多错误,例如:

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】:

    好像您缺少名为 crypto 的包 安装它并再次执行你的程序:pip install pycrypto

    【讨论】:

    • pycrypto是一个废弃的项目,我不建议任何人使用它,有pycryptodome是一个兼容的替代品。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 2016-02-16
    • 1970-01-01
    相关资源
    最近更新 更多