This Python script implements the Vigenere cipher for encrypting and decrypting text based on a provided keyword.
-
Clone the Repository:
https://github.com/d4v1-sudo/vigenere-cipher.git cd vigenere-cipher
-
Run the Script:
python3 vigenere_cipher.py
-
Follow the Prompts:
- Enter the text to be processed.
- Enter the keyword for encryption or decryption.
- Choose to encrypt or decrypt by typing 'e' or 'd' accordingly.
The Python script consists of two functions:
This function generates a key of the same length as the input string by repeating the provided keyword. If the lengths are already equal, the key is returned as is.
This function performs the Vigenere cipher operation on the input string using the provided key and specified mode ('e' for encryption or 'd' for decryption).
- Encryption (
mode == "e"
): Encrypts the input text using the Vigenere cipher. - Decryption (
mode == "d"
): Decrypts the input text using the Vigenere cipher.
Text to process: HelloWorld
Keyword: KEY
Encrypt or decrypt? (Type 'e' or 'd'): e
Ciphertext: RiJvsPvyG
- Make sure to only enter alphabetic characters in the input text.
- The keyword should consist of alphabetic characters only.
Feel free to use and modify the script for your cryptographic needs. If you encounter any issues or have suggestions for improvements, please let us know.