-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVernamStream_Cipher.py.py
42 lines (32 loc) · 1.35 KB
/
VernamStream_Cipher.py.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
#Bug in the Decryptor
while True:
ch =int(input("Press 1 to Encrypt || Press 2 to Decrypt\n>>>"))
if ch == 1:
text = input("text:")
print("!!! KEY MUST BE CHARACTERS !!!\n")
key = input("Key:")
if len(key) != len(text):
key = key*100
else:
pass
tx_ascii = [ord(tx) for tx in text]
ky_ascii = [ord(ky) for ky in key]
charactrize=[]
for as1, as2 in zip(tx_ascii, ky_ascii): #@@@@@@
charactrize.append(chr(as1 ^ as2))
print("================================================")
print(" !!! Encrypted !!! ")
print("text:","".join(charactrize))
print("================================================\n")
elif ch == 2:
text = input("text:")
key = input("Key:")
tx_ascii = [ord(tx) for tx in text]
ky_ascii = [ord(ky) for ky in key]
charactrize=[]
for as1, as2 in zip(tx_ascii, ky_ascii): #@@@@@@
charactrize.append(chr(as2 ^ as1))
print("================================================")
print(" !!! Decrypted !!! ")
print("text:","".join(charactrize))
print("================================================\n")