Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Password Snippet
#5
I hate storing plaintext passwords anywhere. If it's just for you, sure, go right ahead, but once you move to doing "real" applications, using databases and storing *other peoples* info, please use a more secure method. Like a one-way hashing algorithm. For example:
>>> import hashlib
>>> hashlib.sha512('180423'.encode()).hexdigest()
'0b6c4a35b8cfb237fb16e3773cba0a65dd6af67de14f16450e857517a524f46199644add78adc3a966517ea22d7c1cc99dd716db26668b32a4e9d10b5573dc1a'
That big string is what you'd store, so your actual password isn't anywhere in your script. Then, when you get the user's password (via getpass or rawinput), you hash it, and compare the hash with what you previously computed.

That way, even if someone gets smart, they can't open up your script and read the password... (though they can re-write it, or put a different hash in there).
Reply


Messages In This Thread
Password Snippet - by Kai. - Nov-07-2016, 05:22 PM
RE: Password Snippet - by micseydel - Nov-07-2016, 05:40 PM
RE: Password Snippet - by Kai. - Nov-07-2016, 07:18 PM
RE: Password Snippet - by micseydel - Nov-07-2016, 07:19 PM
RE: Password Snippet - by nilamo - Nov-07-2016, 08:58 PM
RE: Password Snippet - by Kai. - Nov-08-2016, 01:22 PM
RE: Password Snippet - by nilamo - Nov-08-2016, 03:31 PM
RE: Password Snippet - by Skaperen - Nov-10-2016, 08:11 AM
RE: Password Snippet - by Larz60+ - Nov-08-2016, 01:34 PM
RE: Password Snippet - by Kai. - Nov-08-2016, 01:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Advanced CLI Snippet Manager bytebutcher 1 2,654 Sep-20-2020, 11:58 AM
Last Post: bytebutcher
  Checkbox snippet menator01 0 2,418 May-16-2020, 08:26 AM
Last Post: menator01
  Cute oscillating range generation snippet I saw on irc league55 1 2,828 Mar-26-2018, 04:19 PM
Last Post: nilamo
  snippet: dp and pv Skaperen 0 2,982 Apr-08-2017, 07:17 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020