-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathabb.py
More file actions
31 lines (23 loc) · 711 Bytes
/
abb.py
File metadata and controls
31 lines (23 loc) · 711 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
30
31
def encrypt(text, s):
result = ""
# transverse the plain text
for i in range(len(text)):
char = text[i]
# Encrypt uppercase characters in plain text
if (char.isupper()):
result += chr((ord(char) + s - 65) % 26 + 65)
# Encrypt lowercase characters in plain text
else:
result += chr((ord(char) + s - 97) % 26 + 97)
return result
def decrypt(text):
trans = ""
for i in range(len(text)):
char = text[i]
pass
# check the above function
text = "CEASER CIPHER DEMO test"
s = 4
print("Plain Text : " + text)
print("Shift pattern : " + str(s))
print("Cipher: " + encrypt(text, s))