-
Notifications
You must be signed in to change notification settings - Fork 0
/
CIPHER.py
41 lines (35 loc) · 1.19 KB
/
CIPHER.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
lower = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
upper = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
encryptdict={}
decryptdict={}
rotation = int(input("What's the rotation size:"))
for l in range(0,len(lower)):
rotator = l+rotation
if rotator >= len(lower):
rotator = rotator-len(lower)
encryptdict.update({lower[l]:lower[rotator]})
encryptdict.update({upper[l]:upper[rotator]})
decryptdict.update({lower[rotator]:lower[l]})
decryptdict.update({upper[rotator]:upper[l]})
def encryptor(string):
string=list(string)
temp=""
for i in range(0,len(string)):
if string[i] == " ":
continue
else:
temp1 = encryptdict.get(string[i])
string[i] = temp1
print (temp.join(string))
def decryptor(string):
string=list(string)
temp=""
for i in range(0,len(string)):
if string[i] == " ":
continue
else:
temp1 = decryptdict.get(string[i])
string[i] = temp1
print (temp.join(string))
print decryptor(string)
print encryptor(string)