sio-2425/delivery1/client/bin/rep_decrypt_file

38 lines
913 B
Python
Executable File

#!/bin/python3
import os
import sys
import logging
logging.basicConfig(format='%(levelname)s\t- %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.INFO)
#send to stdout contents of decrypted file
# encrypted file - encryption metadata
def decryptFile(args):
if len(args) != 3:
logger.error("Need encrypted file and it's metadata.")
sys.exit(-1)
# If first argument is not a file or not found
if (not os.path.isfile(args[1])):
logger.error("File '" + args[1] + "' not found.")
sys.exit(-1)
if (not os.path.isfile(args[2])):
logger.error("File '" + args[2] + "' not found.")
sys.exit(-1)
#Get private key to decrypt
privateKey = ''
#Decrypt file
content = 'decrypt(privateKey, args[1])'
# Send decrypted content to stdout
sys.stdout.write(content)
if __name__ == '__main__':
decryptFile(sys.argv)