'Encrypting and Decrypting Database
I have an encrypted database with columns bookname, author, filename, category.
Now I need to serve the decrypted data to the user, my approach is:
booktitles = libraryfiles.query.all()
dictor = {}
for i in booktitles:
dictor[f"{rsa.decrypt(i.bookname, privateKey).decode()}"] = [rsa.decrypt(i.category, privateKey).decode(),rsa.decrypt(i.filename, privateKey).decode(),rsa.decrypt(i.author, privateKey).decode()]
Recreating the whole database as a dictionary.
Now I have a search functionality which takes "booktitle" and "category"
I filter through the dictionary by:
filtered_dict = {k:v for (k,v) in dictor.items() if request.form['search'] in k and request.form['category'] in v}
Now I'm concerned with the efficiency of this approach as:
I need to for loop through the entire database while performing a decryption on each value
I need to for loop through the dictionary
Instead of querying into the database I'm going to query on the dictionary
Does this kind of approach would cause a massive delay? Or is it the same as querying into a database?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
