Python Forum

Full Version: encrypt data in json file help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello
I am trying to perfect my password manager app and one of the features i want to add is encrypting the json file so that only the user of the program can view the saved passwords. i accessed this article

https://stackoverflow.com/questions/6160...-in-python

that helped me encrypt the file. it worked. when i tried to read the file manually without using the software the content was encrypted. Now when actually writing to the json file new credentials get saved as encrypted code which works as it should however when trying to read the credentials that are saved in the json file i doesnt work as i mean it to. Basically in order to decrypt the data i have to use file.read() function when opening the file. But i want to keep using the json library for reading the files straight into a dictionary. I need to save them as dictionary because well basically that is how i built the whole program around it. For instance the website is the key and the value is a dictionary with username and password as keys and their counterparts as values. This helps me read the information comprehensively and it is easier to access these pieces of information using json. However like i said above in order to decrypt the data i have to use the read function that converts everything to a string. Can someone help me? Been stuck at this for days
When you decrypt the file you should get a string. use json.loads(string) to read the string and create your deictionary.

Post the code. Your description is fuzzy.