私は以下のプログラムを持っています。これは元のメッセージと暗号化されたメッセージを単に出力する別の関数に渡されます。私はどのようにI?PythonでのVigenere暗号プログラムの簡素化
from itertools import cycle
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
def vigenereencrypt(message,keyword):
output = ""
match = zip(message.lower(),cycle(keyword.lower()))
for i in match:
change = (reduce(lambda x, y: alphabet.index(x) + alphabet.index(y), i)) % 26
output = output + alphabet[change]
return output.lower()
素晴らしい。私はそれを3未満です。 – kpie