This repository provides two Python implementations of the Caesar Cipher algorithm: one utilizing recursion and the other employing iteration. The Caesar Cipher is a substitution cipher where each letter in the plaintext is shifted by a fixed number of positions down or up the alphabet.
The Caesar Cipher is one of the simplest and most widely known encryption techniques. In this repository, both recursive and iterative methods are provided to demonstrate different approaches to implementing the cipher.
- Recursive Implementation: Encrypt and decrypt messages using a recursive approach.
- Iterative Implementation: Encrypt and decrypt messages using an iterative approach.
- Encryption and Decryption: Both encryption and decryption functionalities are provided.
- Alphabet Wrapping: Handles wrapping around the alphabet correctly during encryption and decryption.
-
Clone the repository:
git clone https://github.com/cosalt/Recursive-Caesar-Cipher-Algorithm.gitThis command clones the repository to your local machine.
-
Navigate to the project directory:
cd Recursive-Caesar-Cipher-AlgorithmChange into the project directory.
-
Ensure you have Python 3 installed. You can download it from python.org.
Both implementations provide functions to encrypt and decrypt messages.
To encrypt a message, use the encrypt function, specifying the plaintext and the shift key.
from caesar_cipher import encrypt
plaintext = "Hello, World!"
shift_key = 3
ciphertext = encrypt(plaintext, shift_key)
print("Encrypted:", ciphertext)
This script imports the encrypt function, defines a plaintext message and a shift key, encrypts the message, and prints the ciphertext.
To decrypt a message, use the decrypt function, specifying the ciphertext and the shift key.
from caesar_cipher import decrypt
ciphertext = "Khoor, Zruog!"
shift_key = 3
plaintext = decrypt(ciphertext, shift_key)
print("Decrypted:", plaintext)
This script imports the decrypt function, defines a ciphertext message and a shift key, decrypts the message, and prints the plaintext.
The with_recursion.py file contains a recursive implementation of the Caesar Cipher. To use it:
- Open
with_recursion.py. - Follow the instructions within the script to input your message and desired shift key.
The without_recursion.py file provides an iterative implementation of the Caesar Cipher. To use it:
- Open
without_recursion.py. - Follow the prompts to input your message and shift key.
Contributions are welcome! Please fork the repository, create a new branch, and submit a pull request with your proposed changes.