#! /usr/bin/env python3

import os
from cryptography.fernet import Fernet

# find files and add them to a list
files = []

for file in os.listdir():
        if file == 'voldemort.py' or file == "thekey.key" or file == "decrypt.py":
                continue
        if os.path.isfile(file):
                files.append(file);

print(files)

with open("thekey.key", "rb") as key:
        secretkey = key.read()

for file in files:
        with open(file, "rb") as thefile:
                contents = thefile.read()
        contents_decrypted = Fernet(secretkey).decrypt(contents)
        with open(file, "wb") as thefile:
                thefile.write(contents_decrypted)
## notes:
## this script will decrypt files encrypted with encrypt-files.sh, provided you have 
## put the same thekey.key file the previous script generated back into the direcotry
## containing your encrypted files.
## the ownders of this website take no responsibility for errors or loss of data stemming 
## from the use of either encrypt-data.sh or decrypt-data.sh
## THEREFORE you should experiment and learn how to use them before committing 
## vital data to  these procdedures.  Keep in mind that you will require the requisite imported
## libraries for the scripts to function.

