-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaesarcipherproject.py
More file actions
101 lines (82 loc) · 2.22 KB
/
caesarcipherproject.py
File metadata and controls
101 lines (82 loc) · 2.22 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from tkinter import *
from tkinter.ttk import *
rt=Tk()
rt.geometry("750x250")
l0=Label(rt, text="Caesar Cipher", font=("bold", 30))
l0.place(x=240, y=10)
l1=Label(rt, text="Plain_text", font=(22))
l1.place(x=20, y=100)
l2=Label(rt, text="CaesarCipher_text", font=(22))
l2.place(x=20, y=150)
sc1=StringVar()
sc2=StringVar()
ent1=Entry(rt, font=(22), width=50, textvariable=sc1)
ent1.place(x=170, y=100)
ent2=Entry(rt, font=(22), width=50, textvariable=sc2)
ent2.place(x=170, y=150)
l3=Label(rt, text="Shift", font=(22))
l3.place(x=20,y=200)
shift=()
for i in range(0,26):
shift+=i,
chk=Combobox(rt, font=(22), width=6)
chk['values']=shift
chk.current(0)
chk.place(x=90, y=200)
def clear1():
sc1.set("")
btn1=Button(rt, text="Clear", command=clear1())
btn1.place(x=650, y=100)
def clear2():
sc2.set("")
btn2=Button(rt, text="Clear", command=clear2())
btn2.place(x=650, y=150)
def clearall():
sc1.set("")
sc2.set("")
btn3=Button(rt, text="Clear All", command=clearall())
btn3.place(x=250, y=200)
def convert():
if sc1.get()!="" and sc2.get()=="":
a=sc1.get()
b=int(chk.get())
word=""
for i in range(0, len(a)):
if a[i]==" ":
word+=" "
else:
c=a[i]
d=ord(c)
e=d+b
if e>122:
f=e-122
g=f+64
h=chr(g)
word+=h
else:
j=chr(e)
word+=j
sc2.set(word)
elif sc1.get()=="" and sc2.get()!="":
k=sc2.get()
l=int(chk.get())
word2=""
for m in range(0, len(k)):
if k[m]==" ":
word2+=" "
else:
n=k[m]
o=ord(n)
p=o-l
if p<97:
q=97-p
r=123-q
s=chr(r)
word2+=s
else:
t=chr(p)
word2+=t
sc1.set(word2)
btn=Button(rt, text="Convert", command=convert)
btn.place(x=350, y=200)
rt.mainloop()