11import random as ra
22import string as str
33
4+
45def options ():
56 while True :
67 print ("========== Welcome To Message Encryption ==========" )
78 print ("\t '1' For Encryption" )
89 print ("\t '2' For Decode" )
910 try :
1011 opt = int (input ("Enter: " ))
11- if opt not in ("1" ,"2" ,1 , 2 ):
12+ if opt not in ("1" , "2" , 1 , 2 ):
1213 print ("Choose Number Between '1','2'" )
1314 if opt == 1 :
1415 encrypt ()
@@ -17,20 +18,21 @@ def options():
1718 except ValueError :
1819 print ("Enter Numbers Only" )
1920
21+
2022def encrypt ():
2123 x = input ("Enter Your Message :" )
2224
23- if len (x )<= 3 :
25+ if len (x ) <= 3 :
2426 encrypt_key = input ("Enter Your Key '1','4','7' :" )
2527
26- with open ("User_Key.txt" ,"a+" ) as f :
28+ with open ("User_Key.txt" , "a+" ) as f :
2729 f .write (f"{ encrypt_key } ,{ x } \n " )
2830 print (f"Successfully Encrypted: { x [::- 1 ]} " )
2931
3032 encrypt_key = input ("Enter Your Key '1','4','7' :" )
31-
32- with open ("User_Key.txt" ,"a" ) as f :
33- f .write (f"{ encrypt_key } ,{ x } \n " )
33+
34+ with open ("User_Key.txt" , "a" ) as f :
35+ f .write (f"{ encrypt_key } ,{ x } \n " )
3436 shift = x [1 :] + x [0 ]
3537 prefix = "" .join (ra .choice (str .ascii_letters ) for _ in range (3 ))
3638 suffix = "" .join (ra .choice (str .ascii_letters ) for _ in range (3 ))
@@ -39,6 +41,7 @@ def encrypt():
3941 print (f"Successfully Encrypted: { message } " )
4042 return encrypt_key
4143
44+
4245def decode ():
4346 with open ("User_Key.txt" , "r" ) as f :
4447 user_message = input ("Enter Message To Decode : " )
@@ -62,4 +65,5 @@ def decode():
6265 if not found :
6366 print ("Didn't Match :/" )
6467
65- options ()
68+
69+ options ()
0 commit comments