Esempio n. 1
0
 def test_encrypt_decrypt(self):
     config = utils.get_config_parser()
     enc = AESCipher(config.get('AES', 'key'))
     f = open("password.txt", "w+")
     f.write("Password")
     f.close()
     enc.encrypt_file("password.txt", out_filename="password.enc")
     password = enc.decrypt_file("password.enc")
     assert password == "Password", "Failed to decrypt file"
Esempio n. 2
0
import argparse
import sys

parser = argparse.ArgumentParser(
    description='Encryption tool for encrypting whole files in folders')

parser.add_argument("-p", dest="path", type=str, help="Path to folder.")
parser.add_argument("-f", dest="file", type=str, help="Path to file.")
parser.add_argument("-e",
                    dest="encrypt",
                    action="store_true",
                    help="Encrypt every file in folder")
parser.add_argument("-d",
                    dest="decrypt",
                    action="store_true",
                    help="Decrypt every file in folder")

options = parser.parse_args()

if len(sys.argv) < 4:
    parser.print_help()
    sys.exit(1)

# stupid hack to avoid call getPass only when num of args is valid
from AESCipher import AESCipher

if options.file is not None:
    AESCipher.encrypt_file(options)
else:
    AESCipher.encrypt_files_recurcive(options)