예제 #1
0
def main_menu(args):
    # print(args)
    if args[0].lower() == 'init':
        init_function()
    elif args[0].lower() == '--help':
        help()
    elif args[0].lower() == '--version':
        version()
    else:
        fname = args[0]
        cmd = args[1]

        # encrypt file
        if cmd.lower() == 'enc':
            if checkEnc(fname) != False:
                keyFname = message.prompt('File with key for description (' +
                                          STORAGE_DIR + '/' + STORE_KEY_F +
                                          '): ')
                key = getKey() if keyFname == '' else getKey(keyFname)
                encryption(key, fname)
                message.success(fname + ' is now encrypted')
            else:
                message.error(fname + ' is already encrypted')

        # decrypt file
        elif cmd.lower() == 'dec':
            if checkEnc(fname) != False:
                message.error(fname + ' is already decrypted')
            else:
                keyFname = message.prompt('File with key for description (' +
                                          STORAGE_DIR + '/' + STORE_KEY_F +
                                          '): ')
                key = getKey() if keyFname == '' else getKey(keyFname)
                decryption(key, fname)
                message.success(fname + ' is now decrypted')

        # add new keys
        elif cmd.lower() == 'add':
            if checkEnc(fname) != False:
                add(fname)
            else:
                message.error(fname + ' is encrypted')

        # subtract keys
        elif cmd.lower() == 'sub':
            if checkEnc(fname) != False:
                subtract(fname)
            else:
                message.error(fname + ' is encrypted')

        # subtract keys
        elif cmd.lower() == 'mod':
            if checkEnc(fname) != False:
                modify(fname)
            else:
                message.error(fname + ' is encrypted')
예제 #2
0
def op1():
    key = enc.getKey()
    if key != b'':
        enc.decrypt()
        print("Done.")
    else:
        print("Files are already decrypted. Enjoy!")
예제 #3
0
def pdf_to_image(filepath):
	#encrypt file to be uploaded onto IPFS 
	encrypted = encrypt(getKey("abc123"), filepath)
	#try connect to IPFS
	try:
		api = ipfsapi.connect('127.0.0.1', 5001)
		new_file = api.add(encrypted)
		filehash = new_file['Hash']
	except ipfsapi.exceptions.ConnectionError as ce:
		print("Check if Dameon is switched on")
		filehash = " "
	os.remove(encrypted)
	# CHECK IF pdf file
	file_name, extension = os.path.splitext(filepath)
	''' Returns a list of CV2 images which are ready for further preprocessing'''
	#See if in pdf form - otherwise return image path
	if extension == ".pdf":
		imagelist = []
		with(wi(filename=filepath,resolution=400)) as source:
			images=source.sequence
			pages=len(images)
			for i in range(pages):
				wi(images[i]).save(filename=f"{file_name} page {i+1}.png")
				imagelist.append(f"{file_name} page {i+1}.png")
		return imagelist, filehash
	else:
		print("not pdf")
		return filepath, filehash
예제 #4
0
def op2():
    key = enc.getKey()
    if key == b'':
        print("The key is " + str(enc.createNewKey()))
        enc.encrypt()
        print("Done.")
    else:
        print("Files are already encrypted. Wouldn't want to overdo it :3")
예제 #5
0
def op3():
    key = enc.getKey()
    if key == b'':
        print("The key is " + str(enc.createNewKey()))
        enc.encrypt()
    else:
        enc.decrypt()
        print("The key is " + str(enc.createNewKey()))
        enc.encrypt()

    print("Done.")
예제 #6
0
def charge_card(url, data):
    payload = {}
    public_key = os.environ['FLW_PUB_KEY']
    encrypt_key = getKey()
    final = encryptData(encrypt_key, data)
    payload["PBFPubKey"] = public_key
    payload["client"] = final
    payload["alg"] = "3DES-24"
    headers = {'content-type': 'application/json'}
    r = requests.post(url, data=str(json.dumps(payload)), headers=headers)
    response = str(r.text)
    return response
예제 #7
0
with open (config_file, 'r') as f:
    for line in f:
        (key, val) = line.split('=')
        conf[key] = val.strip()

GLOBAL_APP_PW = conf['passkey']

# There is a global password that is asked on opening, and it is required to proceed further
# This has been added for security, as otherwise anyone on the machine can login for free
app_pw = getpass.getpass("Enter password to access app: ")
hash = hashlib.md5(app_pw.encode('utf-8')).hexdigest()
if hash != GLOBAL_APP_PW:
    print ('Wrong password. Exiting')
    exit()

if enc.getKey() == b'':
    initiallyEncrypted = False
else:
    initiallyEncrypted = True
    enc.decrypt()

account = input ("Enter account: ")

file = open(r"data\data.txt", 'r')
data = file.readlines()
file.close()

if initiallyEncrypted:
    enc.createNewKey()
    enc.encrypt()