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
thnx

Edited 5 Years Ago by mools3: n/a

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()
'e28bdbf8faa97dab2203fcc89e397a4bf8d4a5b370421e5481a55f317caee4f81be5a810bb1cffc4695c32198717b9a6e835895852ee3a8689d0963463f2db15'

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 5 Years Ago 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
useraccess={'Dad':'Mysonisawesome'}
f=open('inconspicuosfile.dat','wb+')
pickle.dump(useraccess,f)
f.close()

Edited 5 Years Ago by pyguy62: n/a

This article has been dead for over six months. Start a new discussion instead.