Skip to content

Commit cef5c7d

Browse files
authored
Merge pull request #5 from IshaSah/main
Create Caesar cipher.py
2 parents 22425eb + fc55269 commit cef5c7d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: Caesar cipher.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def encrypt(letter, s):
2+
if (letter.isupper()):
3+
return chr((ord(letter) + s - 65) % 26 + 65) #for uppercase input string
4+
elif (letter.islower()):
5+
return chr((ord(letter) + s - 97) % 26 + 97) #for smallercase input string
6+
else:
7+
return letter
8+
9+
text = input("Enter the word: ")
10+
s = int(input("Enter the shift: "))
11+
shift = [s] * len(text) #shifts the alphabet by input spaces in the english alphabet
12+
result = list(map(encrypt, text, shift))
13+
14+
print("Encrypted text: ", end="")
15+
for i in result:
16+
print(i, end="")

Diff for: README.md

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ This repository contains **Some mini projects** implemented in **Python**
3838

3939
* [commandline_tool](commandline_tool/Command%20Line%20Tool.ipynb)
4040

41+
### Python Ceaser Cipher
42+
43+
![image](https://user-images.githubusercontent.com/68952200/136580945-a477e47e-52aa-41e1-9459-c51f3eee4077.png)
44+
45+
4146
---
4247

4348
## Author

0 commit comments

Comments
 (0)