We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77eeae7 commit 185db23Copy full SHA for 185db23
Encryptio-python-code.py
@@ -0,0 +1,15 @@
1
+# Create a function for Encryption algorithm
2
+def encrpyt_message(text, key):
3
+ encrypted_msg = "" # initially empty string is created
4
+ for char in text:
5
+
6
+ if char.isupper(): # check character is uppercase
7
+ encrypted_msg += chr((((ord(char) + key) -65) % 26) + 65)
8
9
+ elif char.islower(): # checks character is lowercase
10
+ encrypted_msg += chr((((ord(char) + key) -97) % 26) + 97)
11
12
+ else:
13
+ encrypted_msg += char # Numbers, spaces and characters are added as it is.
14
15
+ return encrypted_msg
0 commit comments