https://github.com/fahadelahikhan/caesar-cipher
Simple python script to encode or decode any entered text from the terminal.
https://github.com/fahadelahikhan/caesar-cipher
ceasar-cipher cipher cipher-algorithms encryption-decryption python3
Last synced: about 1 year ago
JSON representation
Simple python script to encode or decode any entered text from the terminal.
- Host: GitHub
- URL: https://github.com/fahadelahikhan/caesar-cipher
- Owner: fahadelahikhan
- License: mit
- Created: 2024-08-29T16:44:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-13T09:11:24.000Z (about 1 year ago)
- Last Synced: 2025-03-13T10:22:16.815Z (about 1 year ago)
- Topics: ceasar-cipher, cipher, cipher-algorithms, encryption-decryption, python3
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Caesar Cipher 🔒


A Python implementation of the classic Caesar Cipher for basic text encryption and decryption.
## 📜 About
The Caesar Cipher is one of the simplest and most widely-known encryption techniques. It works by shifting each letter in the plaintext by a fixed number of positions in the alphabet. This implementation provides a foundation for understanding basic cryptographic concepts.
## ✨ Features
- Encrypt and decrypt text using a shift-based cipher
- Handles both uppercase and lowercase letters
- Preserves non-alphabetic characters
- Simple command-line interface
- Automatic shift normalization for values over 26
## 🚀 Quick Start
### Installation
1. Clone the repository:
```bash
git clone https://github.com/fahadelahikhan/Caesar-Cipher.git
cd Caesar-Cipher
```
2. Run the application:
```bash
python Caesar_Cipher.py
```
### Basic Usage
```python
# Import the caesar function
from caesar_cipher import caesar
# Encrypt a message
encrypted = caesar(start_text="hello", shift_amount=3, cipher_direction="encode")
# Output: Your encoded text is: khoor
# Decrypt a message
decrypted = caesar(start_text="khoor", shift_amount=3, cipher_direction="decode")
# Output: Your decoded text is: hello
```
### Example Encryption
```python
# Encrypt a secret message
message = "meet me after class"
shift = 5
encrypted_message = caesar(message, shift, "encode")
print(encrypted_message) # Output: rjjy rj fiyhw hqfxx
# Decrypt the message
decrypted_message = caesar(encrypted_message, shift, "decode")
print(decrypted_message) # Output: meet me after class
```
## 📖 How It Works
The Caesar Cipher works by:
1. Taking each letter in the plaintext
2. Shifting it by a specified number of positions in the alphabet
3. Wrapping around using modulo 26 arithmetic
4. Non-alphabetic characters are left unchanged
The encryption formula can be represented as:
```
E(x) = (x + n) mod 26
```
Where `x` is the position of the letter in the alphabet and `n` is the shift amount.
## ⚖️ License
Distributed under the MIT License. See [LICENSE](LICENSE) for details.
---
> **Note**: The Caesar Cipher is not secure for modern cryptographic needs. Use this implementation for educational purposes only.