Fork me on GitHub

维吉尼亚

运行环境python3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
key='helloworld'
plaintext='whereisthekey'
#key='relations'
#plaintext='tobeornottobeth'
ascii='abcdefghijklmnopqrstuvwxyz'
keylen=len(key)
ptlen=len(plaintext)
ciphertext = ''
i = 0
while i < ptlen:
j = i % keylen
k = ascii.index(key[j])
m = ascii.index(plaintext[i])
ciphertext += ascii[(m+k)%26]
i += 1
print (ciphertext)

Your support will encourage me to continue to create!