Skip to content

Commit

Permalink
Create caesarcipher.py (#306)
Browse files Browse the repository at this point in the history
* Create caesarcipher.py

This is a simple example of a Caesar Cipher for Hacktoberfest- this is my first-ever pull request! :)

* Updated README to include program in list
  • Loading branch information
rusty-bytes7 authored Oct 11, 2024
1 parent 35f0771 commit 25f422b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ More information on contributing and the general code of conduct for discussion
| Autocomplete Notes App | [AutoCert](https://github.com/DhanushNehru/Python-Scripts/tree/master/Autocomplete%20Notes%20App) | A Python script to auto-generate e-certificates in bulk. |
| Automated Emails | [Automated Emails](https://github.com/DhanushNehru/Python-Scripts/tree/master/Automate%20Emails%20Daily) | A Python script to send out personalized emails by reading a CSV file. |
| Black Hat Python | [Black Hat Python](https://github.com/DhanushNehru/Python-Scripts/tree/master/Black%20Hat%20Python) | Source code from the book Black Hat Python |
| Blackjack | [Blackjack](https://github.com/DhanushNehru/Python-Scripts/tree/master/Blackjack) | A game of Blackjack - let's get a 21. |
| Blackjack | [Blackjack](https://github.com/DhanushNehru/Python-Scripts/tree/master/Blackjack) | A game of Blackjack - let's get a 21.
|Caesar Cipher | [Caesar Cipher](https://github.com/rusty-bytes7/Python-Scripts/blob/e94c8b52d313dc0d66b9ed0b55032c4470f72475/caesarcipher.py) | A Python script to encrypt messages using the Caesar cipher. |
| Chessboard | [Chessboard](https://github.com/DhanushNehru/Python-Scripts/tree/master/Chess%20Board) | Creates a chessboard using matplotlib. |
| Compound Interest Calculator | [Compound Interest Calculator](https://github.com/DhanushNehru/Python-Scripts/tree/master/Calculate%20Compound%20Interest) | A Python script to calculate compound interest. |
| Countdown Timer | [Countdown Timer](https://github.com/DhanushNehru/Python-Scripts/tree/master/Countdown%20Timer) | Displays a message when the Input time elapses. |
Expand Down
21 changes: 21 additions & 0 deletions caesarcipher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#this program is a simple caesar cipher, which encrypts
#a message by shifting each letter three to the right in the alphabet
#this will ignore all characters that are not letters

def caesar_encrypt(plaintext):
#each letter in plaintext
finalstring= ""
for letter in plaintext.lower():
#get the number value of the letter
cipher = (ord(letter)+3)
#wraparound
#checks letter to see if it's out of range
if cipher > 122:
cipher -= 26
finalstring += chr(cipher)
#skips any other characters
elif (ord(letter)) in range (97,123):
finalstring +=chr(cipher)
else:
continue
return(finalstring)

0 comments on commit 25f422b

Please sign in to comment.