基本上标题解释了这个问题,我正在编写一个基本的解密程序,用户输入一个已经加密的数字(指纹)和解密密钥,然后计算出原始的 3 个字母字符串。我不断收到 IndedxError。关于我哪里出错的任何想法?
fingerprint = input("Enter fingerprint: ")
key = input("Enter decryption key: ")
stringList = []
firstchar = (fingerprint - key) % 33
secondchar = fingerprint - ord(stringList[0]) / 33 - key % 33
thirdchar = fingerprint - ord(stringList[1]) / 33 - key % 33
if firstchar == 0 or secondchar == 0 or thirdchar == 0 : #If any of firstchar, secondchar or thirdchar == 0 then add "c" to the list and so on.
stringList.append("c")
elif firstchar == 1 or secondchar == 1 or thirdchar == 1 :
stringList.append("d")
elif firstchar == 2 or secondchar == 2 or thirdchar == 2 :
stringList.append("e")
elif firstchar == 3 or secondchar == 3 or thirdchar == 3 :
stringList.append("f")
elif firstchar == 4 or secondchar == 4 or thirdchar == 4 :
stringList.append("g")
elif firstchar == 5 or secondchar == 5 or thirdchar == 5 :
stringList.append("h")
elif firstchar == 6 or secondchar == 6 or thirdchar == 6 :
stringList.append("i")
elif firstchar == 7 or secondchar == 7 or thirdchar == 7 :
stringList.append("j")
elif firstchar == 8 or secondchar == 8 or thirdchar == 8 :
stringList.append("k")
elif firstchar == 9 or secondchar == 9 or thirdchar == 9 :
stringList.append("l")
elif firstchar == 10 or secondchar == 10 or thirdchar == 10 :
stringList.append("m")
elif firstchar == 11 or secondchar == 11 or thirdchar == 11 :
stringList.append("n")
elif firstchar == 12 or secondchar == 12 or thirdchar == 12 :
stringList.append("o")
elif firstchar == 13 or secondchar == 13 or thirdchar == 13 :
stringList.append("p")
elif firstchar == 14 or secondchar == 14 or thirdchar == 14 :
stringList.append("q")
elif firstchar == 15 or secondchar == 15 or thirdchar == 15 :
stringList.append("r")
elif firstchar == 16 or secondchar == 16 or thirdchar == 16 :
stringList.append("s")
elif firstchar == 17 or secondchar == 17 or thirdchar == 17 :
stringList.append("t")
elif firstchar == 18 or secondchar == 18 or thirdchar == 18 :
stringList.append("u")
elif firstchar == 19 or secondchar == 19 or thirdchar == 19 :
stringList.append("v")
elif firstchar == 20 or secondchar == 20 or thirdchar == 20 :
stringList.append("w")
elif firstchar == 21 or secondchar == 21 or thirdchar == 21 :
stringList.append("x")
elif firstchar == 22 or secondchar == 22 or thirdchar == 22 :
stringList.append("y")
elif firstchar == 23 or secondchar == 23 or thirdchar == 23 :
stringList.append("z")
elif firstchar == 31 or secondchar == 31 or thirdchar == 31 :
stringList.append("a")
elif firstchar == 32 or secondchar == 32 or thirdchar == 32 :
stringList.append("b")
print join(stringList)