-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefFunction.py
More file actions
24 lines (23 loc) · 961 Bytes
/
defFunction.py
File metadata and controls
24 lines (23 loc) · 961 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
#first we need to define parameters and arguments with functions
#encryption function is define with the formulas we will be using further
def encryption(plain_text, shift_key):
cipher_text = ""
for char in plain_text:
if char in alphabet:
position = alphabet.index(char)
new_position = (position + shift_key) % 26
cipher_text += alphabet[new_position]
else:
cipher_text += char
print(f"heres is the text after encryption:{cipher_text}")
#decryption function is define with the formulas we will be using further
def decryption(shift_key, cipher_text):
plain_text = ""
for char in cipher_text:
if char in alphabet:
position = alphabet.index(char)
new_position = (position - shift_key) % 26
plain_text += alphabet[new_position]
else:
plain_text += char
print(f"heres is the text after decryption:{plain_text}")