Skip to content

Commit

Permalink
Available security communication
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed May 31, 2021
1 parent 590ac45 commit fb031c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OSTLibrary.Chats;
using OSTLibrary.Classes;
using OSTLibrary.Networks;
using OSTLibrary.Securities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -95,7 +96,7 @@ static void Recieve()
object pakcetObj = null;
try
{
pakcetObj = Packet.Deserialize(readBuffer);
pakcetObj = Packet.Deserialize(AES256.Decrypt(readBuffer));
}
catch (Exception ex)
{
Expand All @@ -119,7 +120,7 @@ public static void Send(Packet packet)
{
lock (locker)
{
byte[] sendBuffer = packet.Serialize();
byte[] sendBuffer = AES256.Encrypt(packet.Serialize());
byte[] lengthBuffer = BitConverter.GetBytes(sendBuffer.Length);

ns.Write(lengthBuffer, 0, 4);
Expand Down
4 changes: 2 additions & 2 deletions Server/Classes/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void Recieve()
object pakcetObj = null;
try
{
pakcetObj = Packet.Deserialize(readBuffer);
pakcetObj = Packet.Deserialize(AES256.Decrypt(readBuffer));
}
catch (Exception ex)
{
Expand Down Expand Up @@ -256,7 +256,7 @@ public void Send(Packet packet)
{
lock (this)
{
byte[] sendBuffer = packet.Serialize();
byte[] sendBuffer = AES256.Encrypt(packet.Serialize());
byte[] lengthBuffer = BitConverter.GetBytes(sendBuffer.Length);

ns.Write(lengthBuffer, 0, 4);
Expand Down

0 comments on commit fb031c2

Please sign in to comment.