-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrbreaker.py
More file actions
42 lines (35 loc) · 1.27 KB
/
Crbreaker.py
File metadata and controls
42 lines (35 loc) · 1.27 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
L='ABCDEFGHIJKLMNOPQESTUVWXYZ'
#sinartisi kwdikopoihshs
def ceasar_encrypt(ini,steps):
n=len(ini)
ini_output=''
for i in range(n):
character=ini[i]
location=L.find(character)
new_location=(location+steps)%26
ini_output+=L[new_location]
return ini_output
#sinartisi apodikopoihshs
def ceasar_derypt(ini,steps):
n=len(ini)
ini_output=''
for i in range(n):
character=ini[i]
location=L.find(character)
new_location=(location-steps)%26
ini_output+=L[new_location]
return ini_output
W=input('Welcome! insert one of the choices 1)Codification 2)Decoding 3)Exit ')
while W=='2' or W=='1':
if W=='2':
insert=input('insert text for decoding ')
key=int(input('insert the key for decoding '))
F=ceasar_derypt(insert,key)
print ('The coded text:',insert,',translate it into:',F)
elif W=='1':
insert=input('insert text for codification ')
key=int(input('insert the key for the codification '))
F=ceasar_encrypt(insert,key)
print ('The text:',insert,',coded into:',F)
W=input('Insert one of the choices 1)Codification 2)Decoding 3)Exit ')
print ('goodbye')