Skip to content

Commit 77eeae7

Browse files
authored
Update README.md
1 parent 52b7902 commit 77eeae7

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ I recently learned about cryptography and several encryption and decryption algo
1212
- [Hashing](#hashing)
1313
- [Decryption](#decryption)
1414
* [Installation](#installation)
15-
* [Encryption](#encryption)
16-
- [Algorithm](#algorithm)
17-
- [Python code](#python-code)
18-
* [Decryption](#decryption)
19-
- [Algorithm](#algorithm)
20-
- [Python code](#python-code)
15+
* [Encryption Python Code](#encryption-python-code)
16+
* [Decryption Python Code](#decryption-python-code)
2117
* [Conclusion](#conclusion)
2218
* [Contribution](#contribution)
2319

@@ -54,7 +50,28 @@ Decryption is a process of decoding the encoded data. Converting the ciphertext
5450
## Installation
5551
You require python IDE on your laptop/PC.
5652

57-
## Encryption
58-
### Algorithm
53+
## Encryption Python Code
54+
The plain text character is traversed one at a time. Each letter of plain text is replaced by a letter with some fixed number of positions down with alphabet. After the steps is followed, a new string is generated which is referred as cipher text. This algorithm is known as "Caeser Cipher".
55+
```python
56+
# Create a function for Encryption algorithm
57+
def encrpyt_message(text, key):
58+
encrypted_msg = "" # initially empty string is created
59+
for char in text:
60+
61+
if char.isupper(): # check character is uppercase
62+
encrypted_msg += chr((((ord(char) + key) -65) % 26) + 65)
63+
64+
elif char.islower(): # checks character is lowercase
65+
encrypted_msg += chr((((ord(char) + key) -97) % 26) + 97)
66+
67+
else:
68+
encrypted_msg += char
69+
70+
return encrypted_msg
71+
```
72+
73+
## Decryption Python Code
74+
75+
5976

6077

0 commit comments

Comments
 (0)