-
Notifications
You must be signed in to change notification settings - Fork 0
/
ROT13GUI.py
35 lines (28 loc) · 867 Bytes
/
ROT13GUI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from tkinter import *
from tkinter import messagebox
def ROT13():
alphabet = 'abcdefghijklmnopqrstuvwxyz'
nStr = str(n.get()).lower()
keyShift = 13
encryptedString = []
for i in nStr:
if i.isalpha():
shiftLetter = alphabet.index(i) + keyShift
if(shiftLetter > 25):
shiftLetter = alphabet.index(i) - keyShift
encryptedString.append(alphabet[shiftLetter])
else:
continue
messagebox.showinfo("Encrypted text", ''.join(encryptedString))
top = Tk()
top.geometry("150x150")
top.resizable(FALSE, FALSE)
nLabel = Label(top, text="Input a string")
nLabel.pack()
n = Entry(top, bd=5)
n.pack()
Encrypt = Button(top, text="Encrypt", command=ROT13)
Quit = Button(top, text="Quit", command=top.destroy)
Quit.place(x=0, y=125)
Encrypt.place(x=100, y=125)
top.mainloop()