This project demonstrates the implementation of the Vigenère Cipher algorithm, a classical encryption method used for encrypting and decrypting messages. The algorithm was implemented as part of a learning project on freeCodeCamp.
- Encrypt a message using a custom key.
- Decrypt a message using the same key.
- Handles both lowercase and uppercase letters, while ignoring non-alphabet characters.
The Vigenère Cipher works by shifting each letter in the message based on the corresponding letter in the key. The key is repeated as many times as needed to match the length of the message. The shift is calculated by finding the position of the key letter in the alphabet, and then shifting the message letter by that amount.
For encryption, each letter is shifted forward by the position of the corresponding key letter in the alphabet. For decryption, each letter is shifted backward.
- Encrypted Text:
Oabbtiz Vq Pruhdq - Key:
zambak - Decrypted Text:
this is secret
- Clone the repository:
git clone https://github.com/FihriSina/vigenere-cipher.git- Navigate to the project directory:
cd vigenere-cipher- Run the script:
- The Python script can be run as is.
- Modify the
textandcustom_keyvariables to encrypt or decrypt different messages.
-
vigenere(message, key, direction=1): This function takes a message, a key, and a direction (
1for encryption,-1for decryption). It processes each letter in the message and applies the Vigenère Cipher accordingly. -
encrypt(message, key): Calls the
vigenere()function with the direction set to1, returning the encrypted message. -
decrypt(message, key): Calls the
vigenere()function with the direction set to-1, returning the decrypted message.
text = 'Oabbtiz Vq Pruhdq'
custom_key = 'zambak'
decryption = decrypt(text, custom_key)
print(f'Encrypted text: {text}')
print(f'Decrypted text: {decryption}')- Python 3.x
This project is open-source under the MIT license. Feel free to modify and contribute!
Bu proje, mesajları şifrelemek ve çözmek için kullanılan klasik bir şifreleme yöntemi olan Vigenère Şifreleme algoritmasının uygulanmasını göstermektedir. Bu algoritma, freeCodeCamp üzerinde yapılan bir öğrenme projesi olarak geliştirilmiştir.
- Kendi anahtarınızı kullanarak bir mesajı şifreleme.
- Aynı anahtarı kullanarak bir mesajı çözme.
- Küçük ve büyük harflerle çalışır, harf olmayan karakterleri göz ardı eder.
Vigenère Şifreleme, her harfi mesajdaki karşılık gelen anahtar harfine göre kaydırarak çalışır. Anahtar, mesajın uzunluğuna ulaşana kadar tekrar edilir. Anahtar harfinin alfabetedeki pozisyonu kullanılarak, mesajdaki harfe kaydırma yapılır.
Şifreleme için, her harf, karşılık gelen anahtar harfinin pozisyonu kadar ileri kaydırılır. Çözme işlemi ise, her harfi anahtar harfinin pozisyonu kadar geri kaydırır.
- Şifreli Metin:
Oabbtiz Vq Pruhdq - Anahtar:
zambak - Çözülmüş Metin:
this is secret
- Depoyu klonlayın:
git clone https://github.com/FihriSina/vigenere-cipher.git- Proje dizinine gidin:
cd vigenere-cipher- Script'i çalıştırın:
- Python script'i olduğu gibi çalıştırabilirsiniz.
- Farklı mesajları şifrelemek veya çözmek için
textvecustom_keydeğişkenlerini değiştirebilirsiniz.
-
vigenere(message, key, direction=1): Bu fonksiyon bir mesaj, bir anahtar ve bir yön (
1şifreleme,-1çözme) alır. Mesajdaki her harfi işler ve Vigenère şifresini uygular. -
encrypt(message, key):
vigenere()fonksiyonunu1yönüyle çağırarak şifreli mesajı döndürür. -
decrypt(message, key):
vigenere()fonksiyonunu-1yönüyle çağırarak çözülmüş mesajı döndürür.
text = 'Oabbtiz Vq Pruhdq'
custom_key = 'zambak'
decryption = decrypt(text, custom_key)
print(f'Encrypted text: {text}')
print(f'Decrypted text: {decryption}')- Python 3.x
Bu proje MIT lisansı altında açık kaynaklıdır. Değiştirebilir ve katkıda bulunabilirsiniz!