【发布时间】:2021-04-06 05:35:55
【问题描述】:
我想为句子制作一个 vigenere 密码程序。 例如消息是“介绍我最好的朋友卡莉”,关键字是“攀登”
y = "Introducing my best friend carly"
target_length = len(y)
def repeat_string(a_string, target_length):
number_of_repeats = target_length // len(a_string) + 1
a_string_repeated = a_string * number_of_repeats
a_string_repeated_to_target = a_string_repeated[:target_length]
return a_string_repeated_to_target
a_string = "climb"
print (y)
print(repeat_string(a_string, target_length))
输出是
Introducing my friend carly
climbclimbclimbclimbclimbcl
而我想要的输出是
Introducing my friend carly
climbclimbc li mbclim bclim
怎么做?
【问题讨论】:
标签: python cryptography vigenere