-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaeser_Cipher.py
More file actions
32 lines (24 loc) · 1.05 KB
/
Caeser_Cipher.py
File metadata and controls
32 lines (24 loc) · 1.05 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
"""
@author = Abu Zayed
@name = Caeser Cipher
"""
uppercase = ['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']
lowercase = ['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']
new_sentence = ""
shift_value = 7
userInput = input("Write something to encrypt: ")
#check and print section
for x in userInput:
location = 0
if x == " ":
new_sentence = new_sentence + ''.join(" ")
else:
if x in str(lowercase): # x = P
location = lowercase.index(x) # 24, returns the position of y
i = lowercase[(location + shift_value) %26] # returns the letter f
new_sentence = new_sentence + ''.join(i)
elif x in str(uppercase):
location = uppercase.index(x) # 15, returns the position of P
i = uppercase[(location + shift_value) %26] # returns the letter f
new_sentence = new_sentence + ''.join(i)
print(new_sentence)