Hello there,

i'm writing a program (pharmacy gestion), for my dad's pharmacy

and i want to set a password when loging in to the program

and have the ability to change it any time ...

BUT THE PROBLEM IS ... i thinkd to store the password in a text file and load it next login ... but that will reduce the security ( ANY ONE CAN ACCES IT )

i googled it but i found nothing ...

i'm asking if there is a way to store the password in another format or something to solve that ...

Thanks for helping .. any answer is welcomed

i'm using python 2.7 , Tkinter 8

Edited by mools3: n/a

5 Years
Discussion Span
Last Post by pyguy62

You can also use cryptographic solution,python has a good libary build in hashlib .
Here is a quick demo with sha512 that is very safe.

>>> import hashlib
>>> hashlib.sha512("my password").hexdigest()

Here we get 128 character,this is a one way solution.
So how to now that this character 128 is my password?

>>> user_input = hashlib.sha512("my password").hexdigest()
>>> if user_input == 'e28bdbf8faa97dab2203fcc89e397a4bf8d4a5b370421e5481a55f317caee4f81be5a810bb1cffc4695c32198717b9a6e835895852ee3a8689d0963463f2db15'
...     print 'Your password is valid'
Your password is valid

So not so difficult,you just have a bunch 128 character(can use a simple text file)
And iterate trough it to check if password is vaild.

Edited by snippsat: n/a


Both of the above are much better ways to go, but for a simple, not so easy to read solution you could also pickle the dictionary of {username:password} "I'm assuming that's what you're doing pardon me if I'm wrong" to a .dat file. But as I said, this is just a VERY simple solution, and anybody who has a few minutes to spend messing with it could find it.

import pickle

Edited by pyguy62: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.