Update sample codes not indented correctly.

This commit is contained in:
Jason Yang 2021-01-26 17:39:12 +08:00 committed by GitHub
parent bea372f51d
commit 4378dfece7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 131 additions and 131 deletions

View File

@ -2976,7 +2976,7 @@ while True:
ev1, vals1 = win1.Read(timeout=100)
if ev1 == sg.WIN_CLOSED:
break
win1.['_OUTPUT_'].update(vals1[0])
win1['_OUTPUT_'].update(vals1[0])
if ev1 == 'Launch 2' and not win2_active:
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)
```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!!')
```