Update sample codes not indented correctly.
This commit is contained in:
parent
bea372f51d
commit
4378dfece7
|
@ -2976,7 +2976,7 @@ while True:
|
||||||
ev1, vals1 = win1.Read(timeout=100)
|
ev1, vals1 = win1.Read(timeout=100)
|
||||||
if ev1 == sg.WIN_CLOSED:
|
if ev1 == sg.WIN_CLOSED:
|
||||||
break
|
break
|
||||||
win1.['_OUTPUT_'].update(vals1[0])
|
win1['_OUTPUT_'].update(vals1[0])
|
||||||
|
|
||||||
if ev1 == 'Launch 2' and not win2_active:
|
if ev1 == 'Launch 2' and not win2_active:
|
||||||
win2_active = True
|
win2_active = True
|
||||||
|
@ -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)
|
![password hash](https://user-images.githubusercontent.com/13696193/45129441-ab58f000-b151-11e8-8a46-c2789bb7824e.jpg)
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
import hashlib
|
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
|
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
|
1. Choose a password
|
||||||
2. Generate a hash code for your chosen password by running program and entering 'gui' as the 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
|
3. Type password into the GUI
|
||||||
4. Copy and paste hash code Window GUI into variable named login_password_hash
|
4. Copy and paste hash code Window GUI into variable named login_password_hash
|
||||||
5. Run program again and test your login!
|
5. Run program again and test your login!
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Use this GUI to get your password's hash code
|
# Use this GUI to get your password's hash code
|
||||||
def HashGeneratorGUI():
|
def HashGeneratorGUI():
|
||||||
layout = [[sg.T('Password Hash Generator', size=(30,1), font='Any 15')],
|
layout = [[sg.T('Password Hash Generator', size=(30,1), font='Any 15')],
|
||||||
[sg.T('Password'), sg.In(key='password')],
|
[sg.T('Password'), sg.In(key='password')],
|
||||||
[sg.T('SHA Hash'), sg.In('', size=(40,1), key='hash')],
|
[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:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# ----------------------------- Paste this code into your program / script -----------------------------
|
# ----------------------------- Paste this code into your program / script -----------------------------
|
||||||
# determine if a password matches the secret password by comparing SHA1 hash codes
|
# determine if a password matches the secret password by comparing SHA1 hash codes
|
||||||
def PasswordMatches(password, hash):
|
def PasswordMatches(password, hash):
|
||||||
password_utf = password.encode('utf-8')
|
password_utf = password.encode('utf-8')
|
||||||
sha1hash = hashlib.sha1()
|
sha1hash = hashlib.sha1()
|
||||||
sha1hash.update(password_utf)
|
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:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
login_password_hash = '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
|
login_password_hash = '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
|
||||||
password = sg.popup_get_text('Password', password_char='*')
|
password = sg.popup_get_text('Password', password_char='*')
|
||||||
if password == 'gui': # Remove when pasting into your program
|
if password == 'gui': # Remove when pasting into your program
|
||||||
HashGeneratorGUI() # Remove when pasting into your program
|
HashGeneratorGUI() # Remove when pasting into your program
|
||||||
exit(69) # 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')
|
print('Login SUCCESSFUL')
|
||||||
else:
|
else:
|
||||||
print('Login FAILED!!')
|
print('Login FAILED!!')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue