【发布时间】:2018-08-11 19:19:31
【问题描述】:
所以,我正在尝试制作一个可以在 python 3 中加密和解密 vigenere 密码的程序。我这样做是为了练习,但我真的在努力创建密码矩阵。如果你不熟悉 vigenere 密码, here's a helpful photo of what I want.
我必须将第一项切换到最后一项的功能是shift,它运行良好。我只需要创建列表,并将字母表的每个值都转移过来。我的代码如下。
import string
alpha = list(string.ascii_lowercase)
def shift(inList): #Shifts the first item in the list to the end
first = inList[0]
inList.pop(0)
inList.append(first)
return inList
lastList = alpha
cipher = alpha
for item in alpha:
print(alpha.index(item))
cipher = cipher[].append([shift(lastList)])
#global lastList = cipher[-1]
print(lastList)
print(cipher)
我的问题是创建保存 vigenere 密码的二维数组。我似乎无法让它工作。以上是我做的最远的,这个解决方案不会编译。
【问题讨论】:
-
问题是什么?你的解决方案有什么问题?
-
我编辑了问题以使其更清楚。
标签: python string python-3.x encryption vigenere