I DID PROGRESS!
This commit is contained in:
parent
4119a1bbcd
commit
253fdd2a40
6 changed files with 51 additions and 7 deletions
|
@ -2,6 +2,8 @@
|
|||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Cryptography;
|
||||
using System.Linq;
|
||||
|
||||
namespace Client;
|
||||
|
||||
|
@ -9,6 +11,10 @@ public class Program
|
|||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
RSA key = RSA.Create(512);
|
||||
Console.WriteLine($"key: {key.ExportRSAPrivateKey().Length}");
|
||||
Console.WriteLine(key.ExportRSAPublicKeyPem());
|
||||
using TcpClient client = new("127.0.0.1", 12345);
|
||||
|
||||
byte[] toSend = Encoding.ASCII.GetBytes("hello server");
|
||||
|
@ -29,6 +35,15 @@ public class Program
|
|||
await Task.Delay(100);
|
||||
continue;
|
||||
}
|
||||
else if(input.StartsWith('/')) {
|
||||
// Commands :D, i like commands
|
||||
switch(input.ToLower()) {
|
||||
case "/quit":
|
||||
case "/exit":
|
||||
case "/q!":
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
stream.Write(Encoding.ASCII.GetBytes(input));
|
||||
Console.WriteLine($"[{DateTime.Now}]Sent to server: {input}");
|
||||
|
@ -42,7 +57,7 @@ public class Program
|
|||
int readLen = await stream.ReadAsync(buffer);
|
||||
if(readLen != 0) {
|
||||
string fromServer = Encoding.ASCII.GetString(buffer[..readLen]);
|
||||
Console.WriteLine($"[{DateTime.Now}]\t\tFrom server: {fromServer}");
|
||||
Console.WriteLine($"[{DateTime.Now}] From server: {fromServer}");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\lib\lib.csproj" />
|
||||
<ProjectReference Include="..\lib\lib.csproj"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Cryptography" Version="1.0.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue