Fixed up indentation problems... merged back from Jason
This commit is contained in:
parent
d42a0ccfc4
commit
108d5308dc
|
@ -3317,20 +3317,20 @@ Use the upper half to generate your hash code. Then paste it into the code in t
|
|||
![password hash](https://user-images.githubusercontent.com/13696193/45129441-ab58f000-b151-11e8-8a46-c2789bb7824e.jpg)
|
||||
|
||||
```python
|
||||
import PySimpleGUI as sg
|
||||
import hashlib
|
||||
import PySimpleGUI as sg
|
||||
import hashlib
|
||||
|
||||
'''
|
||||
'''
|
||||
Create a secure login for your scripts without having to include your password in the program. Create an SHA1 hash code for your password using the GUI. Paste into variable in final program
|
||||
1. Choose a password
|
||||
2. Generate a hash code for your chosen password by running program and entering 'gui' as the password
|
||||
3. Type password into the GUI
|
||||
4. Copy and paste hash code Window GUI into variable named login_password_hash
|
||||
5. Run program again and test your login!
|
||||
'''
|
||||
'''
|
||||
|
||||
# Use this GUI to get your password's hash code
|
||||
def HashGeneratorGUI():
|
||||
# Use this GUI to get your password's hash code
|
||||
def HashGeneratorGUI():
|
||||
layout = [[sg.T('Password Hash Generator', size=(30,1), font='Any 15')],
|
||||
[sg.T('Password'), sg.In(key='password')],
|
||||
[sg.T('SHA Hash'), sg.In('', size=(40,1), key='hash')],
|
||||
|
@ -3355,9 +3355,9 @@ Use the upper half to generate your hash code. Then paste it into the code in t
|
|||
except:
|
||||
pass
|
||||
|
||||
# ----------------------------- Paste this code into your program / script -----------------------------
|
||||
# determine if a password matches the secret password by comparing SHA1 hash codes
|
||||
def PasswordMatches(password, hash):
|
||||
# ----------------------------- Paste this code into your program / script -----------------------------
|
||||
# determine if a password matches the secret password by comparing SHA1 hash codes
|
||||
def PasswordMatches(password, hash):
|
||||
password_utf = password.encode('utf-8')
|
||||
sha1hash = hashlib.sha1()
|
||||
sha1hash.update(password_utf)
|
||||
|
@ -3367,14 +3367,14 @@ Use the upper half to generate your hash code. Then paste it into the code in t
|
|||
else:
|
||||
return False
|
||||
|
||||
login_password_hash = '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
|
||||
password = sg.popup_get_text('Password', password_char='*')
|
||||
if password == 'gui': # Remove when pasting into your program
|
||||
login_password_hash = '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
|
||||
password = sg.popup_get_text('Password', password_char='*')
|
||||
if password == 'gui': # Remove when pasting into your program
|
||||
HashGeneratorGUI() # Remove when pasting into your program
|
||||
exit(69) # Remove when pasting into your program
|
||||
if PasswordMatches(password, login_password_hash):
|
||||
if PasswordMatches(password, login_password_hash):
|
||||
print('Login SUCCESSFUL')
|
||||
else:
|
||||
else:
|
||||
print('Login FAILED!!')
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue