File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Create a function for Decryption algorithm
2
+ def decrpyt_message (text , key ):
3
+
4
+ decrypted_msg = "" # initially empty string is created
5
+
6
+ for char in text :
7
+
8
+ if char .isupper (): # check character is uppercase
9
+ decrypted_msg += chr ((((ord (char ) - key ) - 65 ) % 26 ) + 65 )
10
+
11
+ elif char .islower (): # checks character is lowercase
12
+ decrypted_msg += chr ((((ord (char ) - key ) - 97 ) % 26 ) + 97 )
13
+
14
+ else :
15
+ decrypted_msg += char # Number, spaces and special charcters are added as it is.
16
+
17
+ return decrypted_msg
18
+
19
+ text = input ("Please Enter your message: " )
20
+ key = int (input ("Enter key value: " ))
21
+
22
+ print ("Your message: " , text )
23
+
24
+ decrpyted_message = decrpyt_message (text , key )
25
+ print ("The Decrypted message is: " , decrpyted_message )
You can’t perform that action at this time.
0 commit comments