

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Encrypt and Decrypt file Code Encrypt: import pyAesCrypt import sys import os
target_dir = "D:\temp\" print(target_dir)
bufferSize = 128 * 1024
password = input("Please input the p: ")
for path, subdirs, files in os.walk(target_dir): for name in files: origin_path = os.path.join(path, name) encrypted_path = os.path.join(path, name+".aes") try:
pyAesCrypt.encryptFile(origin_path, encrypted_path, password, bufferSize)
os.remove(origin_path) except Exception as e: print(e)
Decrypt: import pyAesCrypt import sys import os
target_dir = "D:\temp\" print(target_dir)
bufferSize = 128 * 1024
password = input("Please input the p: ")
for path, subdirs, files in os.walk(target_dir): for name in files: origin_path = os.path.join(path, name) decrypted_path = os.path.join(path, name.strip(".aes")) try:
pyAesCrypt.decryptFile(origin_path, decrypted_path, password, bufferSize)
os.remove(origin_path) except Exception as b: print(b) Result: File encrypted: