This project is an implementation of the Vigenère cipher algorithms in Python. The program enables text encryption and decryption using a key, as well as cryptanalysis, which allows for breaking the encrypted message without knowing the key, based on letter frequency analysis.
- Encryption: Encrypts text from the
plain.txtfile using the key from thekey.txtfile and saves the result tocrypto.txt. - Decryption: Decrypts text from the
crypto.txtfile using the key fromkey.txtand saves the result todecrypt.txt. - Cryptanalysis: Attempts to find the key and decrypt the text from the
crypto.txtfile without the key. Breaking the cipher is based on the index of coincidence method to find the key length and letter frequency analysis. The decrypted text is saved indecrypt.txt, and the found key inkey-found.txt. - Text Preparation: Prepares the plaintext by removing non-alphabetic characters and converting the text to lowercase, saving the result in
plain.txt.
The program is run with one of the following arguments:
-p: Prepares the plaintext.-e: Encrypts.-d: Decrypts.-k: Cryptanalysis.
Usage examples:
python vigenere-cipher.py -e
python vigenere-cipher.py -k
orig.txt: File with the original plaintext (used with the-poption).plain.txt: File with the prepared plaintext.key.txt: File with the key for encryption/decryption.crypto.txt: File with the encrypted text.decrypt.txt: File with the decrypted text.key-found.txt: File with the key found by cryptanalysis.
Author: A. Falkowski | Project created as a programming exercise.