Finished client result API.

Need to work on adjustment user codes and server email notifications.
This commit is contained in:
2021-11-30 18:06:24 +00:00
parent 89bb802e45
commit dcafde1158
15 changed files with 710 additions and 54 deletions

View File

@ -37,11 +37,22 @@ def encrypt(input):
def decrypt(input):
if not check_keyfile_exists():
raise EncryptionKeyMissing
input = input.encode()
_encryption_key = load_key()
fernet = Fernet(_encryption_key)
output = fernet.decrypt(input)
return output.decode()
if type(input) == str:
input = input.encode()
output = fernet.decrypt(input)
return output.decode()
if type(input) == dict:
output = {}
for key, value in input.items():
if type(value) == dict:
output[key] = decrypt(value)
else:
value = value.encode()
output[key] = fernet.decrypt(value)
output[key] = output[key].decode()
return output
class EncryptionKeyMissing(Exception):
def __init__(self, message='There is no encryption keyfile.'):

View File

@ -15,7 +15,7 @@ def decrypt_find(collection:collection, query:dict):
if not query:
output_list.append(decrypted_document)
else:
if set(query.items()).issubset(set(decrypted_document.items())):
if query.items() <= decrypted_document.items():
output_list.append(decrypted_document)
return output_list