-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (49 loc) · 1.61 KB
/
Copy pathmain.py
File metadata and controls
75 lines (49 loc) · 1.61 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import user
gKey = 2
pKey = 23
Alice = user.User(gKey, pKey, secretKey = 5)
Bob = user.User(gKey, pKey, secretKey = 15)
A = Alice.generate_public_key()
B = Bob.generate_public_key()
# Channel = user.Channel()
# Channel.transport(A, Bob)
# Channel.transport(B, Alice)
# sA = Alice.secret_encrypted_key
# sB = Bob.secret_encrypted_key
# # ---
# print(f"Alice's public key: {A}")
# print(f"Bob's public key: {B}")
# print(f"Alice's secret key: {sA}")
# print(f"Bob's secret key: {sB}")
# print("-"*20)
# message = "Привет Боб, я Алиса, как дела?"
# print("Alice encrypted:", message)
# cryptoA = Alice.crypt_message(message, sA)
# print("Alice crypted:", cryptoA)
# Channel.messeging(cryptoA, Bob)
# encrypto = Bob.encrypt_message(cryptoA, sB)
# print("Bob encrypted:", encrypto)
# print("-"*20)
# ---
HackChannel = user.Mellory(gKey, pKey, MellorySecretKey = 6, Alice=Alice, Bob=Bob)
H = HackChannel.generate_public_key()
HackChannel.transport(A, Bob)
HackChannel.transport(B, Alice)
sA = HackChannel.AliceCryptoKey
sB = HackChannel.BobCryptoKey
print(f"Alice's public key: {A}")
print(f"Bob's public key: {B}")
print(f"Alice's secret key: {sA}")
print(f"Bob's secret key: {sB}")
# print(sA == HackChannel.AliceCryptoKey)
# print(sB == HackChannel.BobCryptoKey)
# print(sA == sB)
print("-"*20)
message = "Привет Боб, я Алиса, как дела?"
print("Alice encrypto: ", message)
cryptoA = Alice.crypt_message(message, sA)
print("Alice crypto: ", cryptoA)
HackChannel.messeging(cryptoA, Bob)
encrypto = Bob.encrypt_message(Bob.message, sB)
print("Bob encrypto: ", encrypto)
print("-"*20)