Skip to content
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
45 changes: 45 additions & 0 deletions Caesar_Cipher/Caesar_cipher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class main:
def __init__(self,key:dict) -> None:
self.key = key

def get_input(self) -> None:
while True:
blank_string = str(input("Enter string to decrypt: "))
if blank_string.isalpha():
blank_string = blank_string.lower()
self.blank_string = blank_string
break
else:
print("Input is not valid")
continue

def encrypt_string(self) -> str:
output = ""
for c in self.blank_string:
for k,v in self.key.items():
if k == c:
output += v
else:
continue
self.decrypted_string = output
return(output)

def decrypt_string(self, string: str) -> str:
output = ""
string = string.lower()
string = string.strip()
if string == "":
return(self.blank_string)
else:
for c in string:
for k,v in self.key.items():
if v == c:
output += k

return(output)

if __name__ == "__main__":
key ={"a": "d", "b": "e", "c": "f", "d": "g", "e": "h", "f": "i", "g": "j", "h": "k", "i": "l", "j": "m", "k": "n", "l": "o", "m": "p", "n": "q", "o": "r", "p": "s", "q": "t", "r": "u", "s": "v", "t": "w", "u": "x", "v": "y", "w": "z", "x": "a", "y": "b", "z": "c"}
main = main(key=key)
main.get_input()
print(main.encrypt_string())
39 changes: 39 additions & 0 deletions Caesar_Cipher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--Please do not remove this part-->
![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99)
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)
[![View My Profile](https://img.shields.io/badge/View-My_Profile-green?logo=GitHub)](https://github.com/FH089)

# Caesar Cipher

<p align="center">
<img src="https://images.unsplash.com/photo-1568132930457-20ac2189f20b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1100&q=80" width=50% height=50%>

<!--An image is an illustration for your project, the tip here is using your sense of humour as much as you can :D

You can copy paste my markdown photo insert as following:
<p align="center">
<img src="your-source-is-here" width=40% height=40%>
-->

## 🛠️ Description
<!--Remove the below lines and add yours -->
Simple Caesar Cipher encryptor and decryptor bulit with python

## ⚙️ Languages or Frameworks Used
<!--Remove the below lines and add yours -->
The script was created with Python3 and the built-in functions in it
## 🌟 How to run
<!--Remove the below lines and add yours -->
```bash
python3 caesarcypher.py
Enter string to decrypt: hello
khoor
```
## 📺 Demo
<p align="center">
<img src="https://github.com/ndleah/python-mini-project/blob/main/IMG/caesar-cipher.png" width=70% height=70%>

## 🤖 Author
<!--Remove the below lines and add yours -->
[GitHub](https://github.com/FH089)

Binary file added IMG/caesar-cipher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.