forked from sat5297/hacktober-coding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathceaserCipher.py
More file actions
27 lines (19 loc) · 758 Bytes
/
ceaserCipher.py
File metadata and controls
27 lines (19 loc) · 758 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
def encrypt(message, key):
encryptMessage = ""
for char in message:
# Checking Upper Case.
if (char.isupper()):
encryptCharacter = chr(((((ord(char)+key)-65) % 26) + 65))
encryptMessage += encryptCharacter
# Checking Lower Case.
elif (char.islower()):
encryptCharacter = chr((((ord(char)+key-97) % 26) + 97))
encryptMessage += encryptCharacter
# Checking special symbols.
else:
encryptCharacter = chr((((ord(char)+key-32) % 33) + 32))
encryptMessage += encryptCharacter
return encryptMessage
# Taking input from user.
message = input("Enter the string to encrypt: ")
print("Ceaser Cipher text: ", encrypt(message, 3))