forked from swayam-agrahari/C-Program
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMessage_encryption.py
More file actions
29 lines (29 loc) · 1018 Bytes
/
Message_encryption.py
File metadata and controls
29 lines (29 loc) · 1018 Bytes
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
alpha="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 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"
alpha=alpha.split()
def password(shift,choice):
message=""
messgae_e=input("Enter your messge:\n")
if(choice=="d"):
shift *= -1
for x in range(0,len(messgae_e)):
if messgae_e[x] in alpha:
position=alpha.index(messgae_e[x])
message+=alpha[position+shift]
elif " " in messgae_e[x]:
message+=(f" ")
else:
message+=messgae_e[x]
print(f"Your message is:\n {message}\n")
option=True
while (option):
choice=input("Do you want to encrypt or decrypt your message e or d ?\n")
shift=int(input("Enter the position you want your message to be shifted by?\n"))
while(shift>=25):
shift=shift%25
choice=choice.lower()
password(shift,choice)
still=input("Do you still have any message y or n ? \n")
still=still.lower()
if(still=="n"):
option=False
print("Program Exited! ")