-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubstitution_Cipher_Code.py
54 lines (41 loc) · 1.32 KB
/
Substitution_Cipher_Code.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
import random
characters = " " +"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/*!~@#$%^&()|\/<>:;"
characters = list(characters)
key = characters.copy()
random.shuffle(key)
# print(key)
#Encryption Process
def Encryption():
plain_text = input("Enter The Message To Encrypt : ")
cipher_text = " "
for letter in plain_text:
index = characters.index(letter)
cipher_text += key[index]
print("Original Message is :",plain_text)
print("Encrypted Message is :",cipher_text)
return
#Decryption Process
def Decryption():
cipher_text = input("Enter The Message To Decrypt : ")
plain_text = " "
for letter in cipher_text:
index = key.index(letter)
plain_text += characters[index]
print("Original Message is :",plain_text)
return
def Substitution_Cipher():
while True:
user_input = input('''"What Do You Want To Do?
1.Encryption
2.Decryption
3.Exit : ''')
if user_input == "1":
print("******YOU HAVE SELECTED ENCRYPTION PROCESS*****")
Encryption()
elif user_input == "2":
print("******YOU HAVE SELECTED DECRYPTION PROCESS*****")
Decryption()
else:
print("Exiting...........")
break
Substitution_Cipher()