Пример #1
0
        private void SendMessageRequestHandler()
        {
            Console.WriteLine(Environment.NewLine + "Write your messages");
            Console.WriteLine("Type ~ to exit");

            Console.Write(">");
            string input = Console.ReadLine();

            while (input != "~")
            {
                aesEncryption.SetKey(chatKey);
                byte[] encryptedMessage = aesEncryption.Encrypt(coding.GetBytes(input));

                SendMessageRequest request = new SendMessageRequest
                {
                    ChatName         = chatName,
                    Sender           = UserName,
                    EncryptedMessage = encryptedMessage
                };

                SendMessageAesEncrypted(request, serverKey);

                Console.Write(">");
                input = Console.ReadLine();
            }
        }
Пример #2
0
 internal void SendMessageAesEncrypted <T>(T message, byte[] aesKey) where T : Message
 {
     aesEncryption.SetKey(aesKey);
     tcpClient.Send(aesEncryption.Encrypt(coding.GetBytes(JsonSerializer.Serialize(message))));
 }