Skip to content

Commit

Permalink
Update simpleCipher.py
Browse files Browse the repository at this point in the history
differ empty update, add custom key to enter
  • Loading branch information
MarvinZhong authored Oct 19, 2022
1 parent c77d101 commit 9560d55
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions simpleCipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def main():
# print("Encrypted or Decrypted String\t\t: ", cipher(strInput))
sg.theme('Dark')


layout = [ [sg.Text('Enter String to Encrypt or Decrypt')],
[sg.InputText(key='-strInput-', change_submits=True, size=(39,1))],
[sg.InputText(key='-strInput-', change_submits=True, size=(35,1))],
[sg.Text('Default Key : '),sg.InputText(key='-key-', size=(10,1), default_text="xyz", change_submits=True)],
[sg.Text(key='-Output-'), sg.Button('Copy')] ]

# Create the Window
Expand All @@ -36,12 +38,17 @@ def main():
if event in (None, 'Cancel'):
break
# if -strInput- changed, update the window
if event == '-strInput-':
window['-Output-'].update(cipher(values['-strInput-']))
if event == '-strInput-' or event == '-key-':
# if -strInput- is not empty
if values['-strInput-']:
window['-Output-'].update(cipher(values['-strInput-'], values['-key-']))
if event == 'Copy':
# copy the output to the clipboard
sg.clipboard_set(window['-Output-'].get())
# if -key- over 3 characters, update the window
if len(values['-key-']) > 3 or len(values['-key-']) < 3:
window['-Output-'].update('Key must be exactly 3 characters')
window.close()

if __name__ == '__main__':
main()
main()

0 comments on commit 9560d55

Please sign in to comment.