34 lines
911 B
Python
Executable file
34 lines
911 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
"""Déchiffrement César"""
|
|
|
|
|
|
def main():
|
|
"""Déchiffrement César"""
|
|
|
|
alphabet = "abcdefghijklmnopqrstuvwxyz"
|
|
message = "vcfgrwqwfsbhfsntowbsobgfsbhfsnqvsnjcigsghqsoixcifrviwtshseicwbsgojsnjcigdogeisjcigoihfsgofhwgobgjcigbsrsjsnqwfqizsfrobgzsgfisgzsgxcifgcijfopzsgeiojsqzsggwubsgrsjchfsdfctsggwcbdofzseiszsghhcbashwsf"
|
|
|
|
freq_dict = {}
|
|
|
|
for char in message:
|
|
if char in freq_dict:
|
|
freq_dict[char] += 1
|
|
else:
|
|
freq_dict[char] = 1
|
|
|
|
most_freq = ""
|
|
for char, freq in freq_dict.items():
|
|
if freq == max(freq_dict.values()):
|
|
most_freq = char
|
|
|
|
rotation_steps = list(alphabet).index("e") - list(alphabet).index(most_freq)
|
|
|
|
for char in message:
|
|
index = (list(alphabet).index(char) + rotation_steps) % 26
|
|
print(alphabet[index], end="")
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|