-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
118 lines (101 loc) · 4.09 KB
/
Copy pathProgram.cs
File metadata and controls
118 lines (101 loc) · 4.09 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
namespace bardchat
{
class Program
{
private byte[] bytemessage;
static int Main(string[] args)
{
Console.WriteLine("Client or server? (c or s)");
string socketType_i = Console.ReadLine()!;
Client client;
Server server;
Globals.serverPort = 5003;
if (socketType_i == "c")
{
Console.WriteLine("Enter server IP");
Globals.serverIP = Console.ReadLine()!;
Console.WriteLine("Enter server port");
string serverPort_i = Console.ReadLine()!;
Globals.serverPort = Convert.ToUInt16(serverPort_i);
client = new Client();
client.LoopConnect();
Console.WriteLine("Enter username:");
string username = Console.ReadLine();
do
{
enterRequest:
Console.WriteLine("Enter request for server");
string request_i = Console.ReadLine()!;
if (request_i == "SEND")
{
Console.WriteLine("Enter ip address.");
string inputtedAddress = Console.ReadLine();
/*
if (!_currentClients.Contains(inputtedAddress))
{
Console.WriteLine("IP address is incorrect or not connected.");
goto enterRequest;
}
else
{
*/
Console.WriteLine("IP Address is valid. Enter in message:");
string message = Console.ReadLine();
Console.WriteLine("Encrypted message:");
Console.WriteLine(BRHasher.HashText(message, message));
Console.WriteLine("Decrypted message:");
Console.WriteLine(message);
//client?.Send(username, "SENT:"+BRHasher.HashText(message, message).ToString());
bytemessage = Encoding.ASCII.GetBytes(message);
client?.Send("SENT:"+BRC2.EncodeText(bytemessage, message, 0));
goto enterRequest;
//}
}
client?.Send(request_i);
}
while
(true);
}
else if (socketType_i == "s")
{
Console.WriteLine("Starting server...");
server = new Server(5);
Console.WriteLine(Globals.serverPort);
server.Start();
Console.WriteLine("Server started.");
}
else
{
Console.WriteLine("That is not a valid input");
}
Console.ReadLine();
return 0;
/*Contact contact1 = new Contact(Guid.NewGuid());
Contact contact2 = new Contact(Guid.NewGuid());
Client client = new Client();
client.GenerateNewKey();
Console.WriteLine("CLIENTS KEY IS " + Convert.ToBase64String(client.key));
Chat chat = new Chat();
chat.name = "badlands";
chat.AddMember(contact1);
chat.AddMember(contact2);
Chat chat2 = new Chat();
chat2.name = "the chat";
chat2.AddMember(contact1);
chat2.AddMember(contact2);
chat2.AddMember(new Contact(Guid.NewGuid()));
client.AddChat(chat);
client.AddChat(chat2);
Console.WriteLine("Addded chat to client with 2 members");
for (int i = 0; i < client.chats.Count; i++)
{
Console.WriteLine("CHAT " + client.chats[i].name);
foreach (var c in client.chats[i].members)
{
Console.WriteLine(c.Key);
}
}
return 0;*/
}
}
}