-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathawe.py
70 lines (59 loc) · 1.88 KB
/
awe.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Taschenrechner GUI in Python
# by YL aka dd2
from tkinter import *
window = Tk()
window.title("AWE Projekt Encryption/Decryption")
window.geometry("500x160")
eingabe = Text(window, width=200, height=4)
eingabe.pack()
def c2n():
alphabet = "abcdefghijklmnopqrstuvwxyz"
k = 3
c = ''
code = ''
try:
code = str(eingabe.get('1.0',END))
code = code.lower()
code = code.replace("\n","")
except:
label1.configure(text="Es ist ein Fehler aufgetreten!")
finally:
if code.isalpha():
for z in code:
if z == ' ':
c += z
elif z in alphabet:
c += alphabet[(alphabet.index(z) + k) % (len(alphabet))]
label1.configure(text=(str(c)))
else:
label1.configure(text="Bitte nur Buchstaben eingeben, keine Zahlen, Sonderzeichen etc.")
def n2c():
alphabet = "abcdefghijklmnopqrstuvwxyz"
k = 3
c = ''
code = ''
try:
code = str(eingabe.get('1.0',END))
code = code.lower()
code = code.replace("\n","")
except:
label1.configure(text="Es ist ein Fehler aufgetreten!")
finally:
if code.isalpha():
for z in code:
if z == ' ':
c += z
elif z in alphabet:
c += alphabet[(alphabet.index(z) - k) % (len(alphabet))]
label1.configure(text=(str(c)))
else:
label1.configure(text="Bitte nur Buchstaben eingeben, keine Zahlen, Sonderzeichen etc.")
buttonc2n = Button(window, text="caesar -> original", command=c2n)
buttonc2n.pack(fill=BOTH)
buttonn2c = Button(window, text="original -> caesar", command=n2c, height=1, width=1)
buttonn2c.pack(fill=BOTH)
text2 = Label(window, text="=")
text2.pack()
label1 = Label(text="Output will be displayed here!")
label1.pack()
window.mainloop()