アットウィキロゴ

kつう

def decode(ww,key_open):
 
    rev=""
    for w1 in ww:
        sx=dic.index(w1)
        sx=sx+key_open
        if sx>25:sx=sx-25
        if sx<0:sx=sx+25
        rev=rev+dic[sx]
 
    return rev
 
def code(ww,key):
 
    rev=""
    for w1 in ww:
        sx=dic.index(w1)
        sx=sx+key
        if sx>25:sx=sx-25
        if sx<0:sx=sx+25
        rev=rev+dic[sx]
 
    return rev
 
dx="abcdefghijklmnopqrstuvwxyz"
dic=[]
for d1 in dx:
    dic.append(d1)
 
w="phi"
key=2
key_open=-key
 
ch=code(w,key)
 
rev=decode(ch,key_open)
 
print(rev)
 
最終更新:2018年02月08日 10:30