-
Notifications
You must be signed in to change notification settings - Fork 0
/
toy.py
52 lines (39 loc) · 1.38 KB
/
toy.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
47
48
49
50
51
52
from quantum import senderProg,receiverProg,makeKey
userinput = input("What is your 8 character message?: ")
l,m=[],[]
sendermessage = []
for i in userinput:
l.append(ord(i))
#print(l)
for i in l:
m.append(int((str(bin(i)))[2:]))
#print(m)
for bin in m:
sendermessage.append("0")
for num in str(bin):
sendermessage.append(num)
#print(userinput)
n = len(sendermessage)
#print(n)
try:
x,senderBasess,sendermessages = senderProg(sendermessage,n)
#print(type(x[0]))
#print("\nENCODED: ", x)
print("\nSender Bases: ", senderBasess)
print("\nSender Message: ", sendermessages)
receiverResults,receiverBases = receiverProg(x,n)
print("\nReciever Bases: ", receiverBases)
print("\nReciever Results: ", receiverResults)
key = makeKey(senderBasess,receiverResults,receiverBases,sendermessages,sendermessages,n)
print("\nFINAL KEY: " ,str(key))
except IndexError:
x,senderBasess,sendermessages = senderProg(sendermessage,n)
print(type(x[0]))
print("\nENCODED: ", x)
print("\nSender Bases: ", senderBasess)
print("\nSender Message: ", sendermessages)
receiverResults,receiverBases = receiverProg(x,n)
print("\nReciever Bases: ", receiverBases)
print("\nReciever Results: ", receiverResults)
key = makeKey(senderBasess,receiverResults,receiverBases,sendermessages,sendermessages,n)
print("\nFINAL KEY: " ,str(key))