| 22 | def main(): |
| 23 | # Use this GUI to get your password's hash code |
| 24 | def HashGeneratorGUI(): |
| 25 | layout = [ |
| 26 | [sg.Text('Password Hash Generator', size=(30, 1), font='Any 15')], |
| 27 | [sg.Text('Password'), sg.Input(key='-password-')], |
| 28 | [sg.Text('SHA Hash'), sg.Input('', size=(40, 1), key='hash')], |
| 29 | ] |
| 30 | |
| 31 | window = sg.Window('SHA Generator', layout, |
| 32 | auto_size_text=False, |
| 33 | default_element_size=(10, 1), |
| 34 | text_justification='r', |
| 35 | return_keyboard_events=True, |
| 36 | grab_anywhere=False) |
| 37 | |
| 38 | while True: |
| 39 | event, values = window.read() |
| 40 | if event == sg.WIN_CLOSED: |
| 41 | break |
| 42 | |
| 43 | password = values['-password-'] |
| 44 | try: |
| 45 | password_utf = password.encode('utf-8') |
| 46 | sha1hash = hashlib.sha1() |
| 47 | sha1hash.update(password_utf) |
| 48 | password_hash = sha1hash.hexdigest() |
| 49 | window['hash'].update(password_hash) |
| 50 | except: |
| 51 | pass |
| 52 | window.close() |
| 53 | |
| 54 | # ----------------------------- Paste this code into your program / script ----------------------------- |
| 55 | # determine if a password matches the secret password by comparing SHA1 hash codes |