diff --git a/polyalphabetic_cipher b/polyalphabetic_cipher index bd2209cc0..8771cbffc 100644 --- a/polyalphabetic_cipher +++ b/polyalphabetic_cipher @@ -8,14 +8,14 @@ def encrypt(text, key): key_index = 0 for char in text: - if char.isalpha(): + if char.isalpha(): shift = ord(key[key_index]) - ord('A') if char.isupper(): new_char = chr((ord(char) - ord('A') + shift) % 26 + ord('A')) else: new_char = chr((ord(char) - ord('a') + shift) % 26 + ord('a')) encrypted_text.append(new_char) - key_index = (key_index + 1) % key_length + key_index = (key_index + 1) % key_length else: encrypted_text.append(char) @@ -31,14 +31,14 @@ def decrypt(text, key): key_index = 0 for char in text: - if char.isalpha(): + if char.isalpha(): shift = ord(key[key_index]) - ord('A') if char.isupper(): new_char = chr((ord(char) - ord('A') - shift) % 26 + ord('A')) else: new_char = chr((ord(char) - ord('a') - shift) % 26 + ord('a')) decrypted_text.append(new_char) - key_index = (key_index + 1) % key_length + key_index = (key_index + 1) % key_length else: decrypted_text.append(char)