发布网友 发布时间:2022-04-22 09:09
共1个回答
热心网友 时间:2022-04-19 04:24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
alp='abcdefghijklmnopqrstuvwxyz01234567 '
def num2alp(c):
a = alp[c]
return(a)
def alp2num(d):
if d != ' ':
return((ord(d)-97)%37)
else:
return 36
def envVigenere(key,plaintext):
m = len(plaintext)
n = len(key)
etext = ""
for i in range(m):
p = plaintext[i]
k = key[i%n]
num1 = alp2num(p)
num2 = alp2num(k)
num3 = (num1+num2)%37
f = num2alp(num3)
etext = etext + f
return(etext)
print(envVigenere('lemon','attack at dawn'))