This project implements a Vigenère cipher in Python. The script can both encrypt and decrypt text using a provided key.
-
Encryption and Decryption:
Uses a Vigenère cipher algorithm to shift characters based on a repeating key. -
Flexible Input:
- Converts all letters to lowercase before processing.
- Leaves non-alphabet characters (such as spaces, numbers, or punctuation) unchanged.
-
Reusable Functions:
Contains helper functionsencrypt()anddecrypt()that wrap the mainvigenere()function.
-
Vigenère Function:
For each letter in the input message, the function:- Finds the corresponding letter in the key (cycling through the key with modulo arithmetic).
- Determines the shift (offset) using the position of the key letter in the alphabet.
- Applies the shift (addition for encryption, subtraction for decryption) to the message character.
-
Encryption vs. Decryption:
The function takes an optional parameterdirection:- A value of
1encrypts the text. - A value of
-1decrypts the text.
- A value of
-
Clone the Repository:
git clone https://github.com/yourusername/your-repo-name.git
-
Navigate to the Project Directory:
cd vigenere_Python_Cypher
3.Run the Script:
python vigenere.py
*(Make sure you have Python 3 installed on your system.)*
Contributions are welcome! Feel free to fork this repository, improve the code, or add new features. When submitting pull requests, please include a brief description of your changes.
This project is open source and available under the [MIT License]
- g3tech
- freecodecamp