diff --git a/chapter_one/Multiplikative_Chiffre.py b/chapter_one/Multiplikative_Chiffre.py index 1dc57b3..b885df6 100644 --- a/chapter_one/Multiplikative_Chiffre.py +++ b/chapter_one/Multiplikative_Chiffre.py @@ -18,8 +18,8 @@ def encrypt_text(cleartext: str, key: int): for char in cleartext: index = au.get_index_of_letter(char) - newIndex = (index * key) % 26 - resulting += au.get_letter_at_index(newIndex) + new_index = (index * key) % 26 + resulting += au.get_letter_at_index(new_index) return resulting @@ -41,8 +41,8 @@ def decrypt_text(ciphertext: str, key: int): for char in ciphertext: index = au.get_index_of_letter(char) - newIndex = (index * decrypt_key) % 26 - resulting += au.get_letter_at_index(newIndex) + new_index = (index * decrypt_key) % 26 + resulting += au.get_letter_at_index(new_index) return resulting diff --git a/chapter_one/Permutations-Chiffre.py b/chapter_one/Permutations-Chiffre.py index dbcc97e..849ee4d 100644 --- a/chapter_one/Permutations-Chiffre.py +++ b/chapter_one/Permutations-Chiffre.py @@ -13,10 +13,10 @@ def encrypt_text(cleartext: str, key: [int]): resulting = '' for char in cleartext: - charIndex = au.get_index_of_letter(char) - cipherIndex = key.index(charIndex) - cipherChar = au.get_letter_at_index(cipherIndex) - resulting += cipherChar + char_index = au.get_index_of_letter(char) + cipher_index = key.index(char_index) + cipher_char = au.get_letter_at_index(cipher_index) + resulting += cipher_char return resulting @@ -31,10 +31,10 @@ def decrypt_text(ciphertext: str, key: [int]): resulting = '' for char in ciphertext: - charIndex = au.get_index_of_letter(char) - clearIndex = key[charIndex] - clearChar = au.get_letter_at_index(clearIndex) - resulting += clearChar + char_index = au.get_index_of_letter(char) + clear_index = key[char_index] + clear_char = au.get_letter_at_index(clear_index) + resulting += clear_char return resulting @@ -50,20 +50,22 @@ def generate_key(): return indices + def generate_key_with_keyword(keyword: str): result = [] for char in keyword: - charIndex = au.get_index_of_letter(char) - if charIndex not in result: - result.append(charIndex) + char_index = au.get_index_of_letter(char) + if char_index not in result: + result.append(char_index) - remainingIndices = [i for i in range(26-len(result))] + remaining_indices = [i for i in range(26 - len(result))] - result.extend(remainingIndices) + result.extend(remaining_indices) return result + if __name__ == '__main__': key = generate_key_with_keyword('patrick') print(key) diff --git a/chapter_one/Tausch-Chiffre.py b/chapter_one/Tausch-Chiffre.py index 03fd32f..44c0131 100644 --- a/chapter_one/Tausch-Chiffre.py +++ b/chapter_one/Tausch-Chiffre.py @@ -23,8 +23,8 @@ def encrypt_text(cleartext: str, key1: int, key2: int): for char in cleartext: index = au.get_index_of_letter(char) - newIndex = (index * key1 + key2) % 26 - resulting += au.get_letter_at_index(newIndex) + new_index = (index * key1 + key2) % 26 + resulting += au.get_letter_at_index(new_index) return resulting @@ -51,8 +51,8 @@ def decrypt_text(ciphertext: str, key1: int, key2: int): for char in ciphertext: index = au.get_index_of_letter(char) - newIndex = ((index - key2) * decrypt_key1) % 26 - resulting += au.get_letter_at_index(newIndex) + new_index = ((index - key2) * decrypt_key1) % 26 + resulting += au.get_letter_at_index(new_index) return resulting