I tried to run this code using both Python and Python 3 on my machine, but it has many errors such as:
python3 gen.py
Output:
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'
And:
python gen.py
Output:
Traceback (most recent call last):
File "gen.py", line 1, in <module>
from Crypto.Cipher import DES
ImportError: No module named Crypto.Cipher
Code
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)