隔离变量名中的数字,Casers Cipher加密和解密

时间:2017-01-16 12:00:23

标签: python encryption

在顶部,我需要帮助尝试让用户输入自定义shift键,所以我试图隔离列表/变量名中的每个数字,以便当用户输入一个我可以匹配的数字时它到var_alpha的孤立变量,然后一旦选择了var_alpha,就可以将正确的var_alpha输入到加密代码中 - 对于for letter in var_word: var_nword = var_alpha3[var_alpha.index(letter)] print(var_nword, end= "")中的字母

def Procedure_E():
var_shiftkey = input ("What is yor shift key")
if var_shiftkey == var_alpha[" "]:
    for letter in var_word:
        var_nword = var_alpha("")[var_alpha.index(letter)]
        print(vr_nword, end= "")

var_word = input("Type the word or phrase you want to encrypt")
var_word = var_word.lower()
var_alpha = list("abcdefghijklmnopqrstuvwxyz")
var_alpha[1] = list("bcdefghijklmnopqrstuvwxyza")
var_alpha[2] = list("cdefghijklmnopqrstuvwxyzab")
var_alpha[3] = list("defghijklmnopqrstuvwxyzabc")
var_alpha[4] = list("efghijklmnopqrstuvwxyzabcd")
var_alpha[5] = list("fghijklmnopqrstuvwxyzabcde")
var_alpha[6] = list("ghijkllmnopqrstuvwxyzabcdef")
var_alpha[7] = list("hijklmnopqrstuvwxyzabcdefg")
var_alpha[8] = list("ijklmnopqrstuvwxyzabcdefgh")
var_alpha[9] = list("jklmnopqrstuvwxyzabcdefghi")
var_alpha[10] = list("klmnopqrstuvwxyzabcdeghij")
var_alpha[11] = list("lmnopqrstuvwxyzabcdefghijk")
var_alpha[12] = list("mnopqrstuvwxyzabcdefghijkl")
var_alpha[13] = list("nopqrstuvwxyzabcdefghijklm")
var_alpha[14] = list("opqrstuvwxyzabcdefghijklmn")
var_alpha[15] = list("pqrstuvwxyzabcdefghijklmno")
var_alpha[16] = list("qrstuvwxyzabcdefghijklmnop")
var_alpha[17] = list("rstuvwxyzabcdefghijklmnopq")
var_alpha[18] = list("stuvwxyzabcdefghijklmnopqr")
var_alpha[19] = list("tuvwxyzabcdefghijklmnopqrs")
var_alpha[20] = list("uvwxyzabcdefghijklmnopqrst")
var_alpha[21] = list("vwxyzabcdefghijklmnopqrstu")
var_alpha[22] = list("wxyzabcdefghijklmnopqrstuv")
var_alpha[23] = list("xyzabcdefghijklmnopqrstuvw")
var_alpha[24] = list("yzabcdefghijklmnopqrstuvwx")
var_alpha[25] = list("zabcdefghijklmnopqrstuvwxy")
for letter in var_word:
    var_nword = var_alpha3[var_alpha.index(letter)]
    print(var_nword, end= "")



 def Procedure_D():
var_dword = input("Enter the word you would like to decrypt")
var_dword = var_dword.lower()
var_alpha = list("abcdefghijklmnopqrstuvwxyz")
var_alpha3 = list("defghijklmnopqrstuvwxyzabc")
for letter in var_dword:
    var_xword = var_alpha[var_alpha3.index(letter)]
    print(var_xword, end= "")var_choice = input("WOULD YOU LIKE TO (E)NCRYPT OR (D)ECRYPT")

var_choice = var_choice.upper()

if var_choice == "E" or "ENCRYPT":
Procedure_E()

否则:     Procedure_D()

0 个答案:

没有答案