diff --git a/Caesar_Cipher/Caesar_cipher.py b/Caesar_Cipher/Caesar_cipher.py new file mode 100644 index 00000000..ac514ef3 --- /dev/null +++ b/Caesar_Cipher/Caesar_cipher.py @@ -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()) diff --git a/Caesar_Cipher/README.md b/Caesar_Cipher/README.md new file mode 100644 index 00000000..416c17a9 --- /dev/null +++ b/Caesar_Cipher/README.md @@ -0,0 +1,39 @@ + + + +[](https://github.com/FH089) + +# Caesar Cipher + +
+
+
+
+
+## 🛠️ Description
+
+Simple Caesar Cipher encryptor and decryptor bulit with python
+
+## ⚙️ Languages or Frameworks Used
+
+The script was created with Python3 and the built-in functions in it
+## 🌟 How to run
+
+```bash
+python3 caesarcypher.py
+Enter string to decrypt: hello
+khoor
+```
+## 📺 Demo
+
+
+
+## 🤖 Author
+
+[GitHub](https://github.com/FH089)
+
diff --git a/IMG/caesar-cipher.png b/IMG/caesar-cipher.png
new file mode 100644
index 00000000..4fcb61da
Binary files /dev/null and b/IMG/caesar-cipher.png differ