Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Caesar cipher.py #5

Merged
merged 3 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Caesar cipher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def encrypt(letter, s):
if (letter.isupper()):
return chr((ord(letter) + s - 65) % 26 + 65) #for uppercase input string
elif (letter.islower()):
return chr((ord(letter) + s - 97) % 26 + 97) #for smallercase input string
else:
return letter

text = input("Enter the word: ")
s = int(input("Enter the shift: "))
shift = [s] * len(text) #shifts the alphabet by input spaces in the english alphabet
result = list(map(encrypt, text, shift))

print("Encrypted text: ", end="")
for i in result:
print(i, end="")
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ This repository contains **Some mini projects** implemented in **Python**

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

### Python Ceaser Cipher

![image](https://user-images.githubusercontent.com/68952200/136580945-a477e47e-52aa-41e1-9459-c51f3eee4077.png)


---

## Author
Expand Down