-
Notifications
You must be signed in to change notification settings - Fork 0
/
vigener_cipher.py
46 lines (34 loc) 路 1 KB
/
vigener_cipher.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#-*-coding:utf8;-*-
#qpy:3
#qpy:console
'''
@Vigener's Cipher@
Comments:
You can change the array with the alphabet to your language,
and the program will work with your language.
Also, pay attention to the line with the switch, changing +/-,
you can change the program for encryption / decryption.
Author: Nazar Ponochevnyi
'''
# Alphabet (you can change)
A = ['袗','袘','袙','袚','袛','袝','衼','袞','袟','袠','袡','袣','袥','袦','袧','袨','袩','袪','小','孝','校','肖','啸','笑','效','楔','些','歇','蝎','鞋','协','挟','携']
# Input values
text = input('\nInput text: ').upper()
key = input('\nInput key: ').upper()
# Basic processes
i = 0
result = ''
for t in text:
if A.count(t) != 0:
if i == len(key):
i = 0
sm = A.index(key[i]) + 1
pos = A.index(t) + sm #!!! Toggle (+/-) !!!
if pos >= len(A):
pos -= len(A)
result += A[pos]
i += 1
else:
result += t
# Output values
print('\nEncrypted/Decrypted text:', result)