0

i want to create a desktop application that will take an input (email and password) and store it for later use in my tkinter app. How can i store this data in a secure way on the user's end so on their laptop locally where i can access it every time the user opens the application it will auto sign them in. i don't want to create a server on my end or make a website or a database.

i just want to store the data locally with python and have access to it in a secure way.

thx in advanced :)

1 Answers1

1

Save the data:

import json
data = {"username":"username","password":"123"}
with open('data.json', 'w+') as outfile:
    json.dump(data, outfile, indent=4) 

Open the data

import json
with open("data.json") as file:
  data = json.load(file)

this will save all the stuff in the data dictionary and you'll be able to access it from a file called data.json in the same directory of the python file.

  • thx, but regarding the password i want to encrypt it then decrypt it, what would u suggest ? – Abed Al Ghani Shaaban Jun 21 '22 at 19:30
  • I think you mean `hashing` not `encrypting` they're 2 different things. Passwords are usually hashed then to check the validity you hash the input and compare both. I suggest looking into a module called `hashlib` in python for hashing. https://stackoverflow.com/questions/326699/difference-between-hashing-a-password-and-encrypting-it – pleasedontdownvote Jun 25 '22 at 16:19
  • but since i want to get its value again i can decrypt it but can't dehash it – Abed Al Ghani Shaaban Jun 27 '22 at 19:51
  • Yes you're not supposed to "dehash". if you want to check if a password is write then you could just hash the input and see if both hashes match. – pleasedontdownvote Jun 28 '22 at 13:38