クラシック暗号学

2748 ワード

import string
x=list(input())
a=list()
b=len(x)
for i in range(0,b):
    a.append(ord(x[i]))
for c in range(0,2**(b-1)):
    s = bin(c).replace("0b", "")
    v=len(s)
    if v < b-1:
        for i in range(0, b - v-1):
            s = '0' + s
    print(s)
    for i in range(1,b):
        m=0
        for j in range(0,i):
            for z in range(j,b,i):
                if m
x={0:'A',1:'B', 2:'C', 3:'D', 4:'E', 5:'F', 6:'G', 7:'H', 8 :'I',9 :'J',10 :'K',11 :'L',12 :'M',13:'N', 14:'O', 15 :'P',16 :'Q',17 :'R',18:'S', 19:'T', 20:'U', 21:'V', 22:'W', 23:'X', 24:'Y', 25:'Z',}
b={'A':0,'B':1, 'C':2, 'D':3, 'E':4, 'F':5, 'G':6, 'H':7, 'I':8,'J':9,'K':10,'L':11,'M':12,'N':13, 'O':14,'P':15,'Q':16,'R':17,'S':18, 'T':19, 'U':20, 'V':21, 'W':22, 'X':23, 'Y':24, 'Z':25,}
c=list(input())
s=list(input())
f=list()
for i in range(0,len(c)):
    d=x[(b[c[i]]+b[s[i]])%26]
    f.append(d)
print(f)
import numpy as np
x={0:'A',1:'B', 2:'C', 3:'D', 4:'E', 5:'F', 6:'G', 7:'H', 8 :'I',9 :'J',10 :'K',11 :'L',12 :'M',13:'N', 14:'O', 15 :'P',16 :'Q',17 :'R',18:'S', 19:'T', 20:'U', 21:'V', 22:'W', 23:'X', 24:'Y', 25:'Z',}
b={'A':0,'B':1, 'C':2, 'D':3, 'E':4, 'F':5, 'G':6, 'H':7, 'I':8,'J':9,'K':10,'L':11,'M':12,'N':13, 'O':14,'P':15,'Q':16,'R':17,'S':18, 'T':19, 'U':20, 'V':21, 'W':22, 'X':23, 'Y':24, 'Z':25,}
e=list(input())
c=list()
for i in range(0,len(e)):
    c.append(b[e[i]])
a = np.array([[6,24,1],[13,16,10],[20,17,15]])
s=list()
m=list()
q=len(e)+(len(e)%3)
for i in range(len(e)-1,q):
    c.append(25)
for i in range(0,q,3):
    for j in range(i,i+3):
        s.append(c[j])
    d=np.array([s])
    h=np.dot(a,np.transpose(d))
    s=[]
    for j in range(0,3):
        m.append((h[j][0])%26)
for i in range(0,len(m)):
    print(x[m[i]],end=" ")