Example #1
0
        public void NetworkSendInfo(NetworkStream stream, DIFFIE_HELMAN aes)
        {
            string hierarhy = GetInfo();                 //Массив стрингов

            byte[] arr = new byte[hierarhy.LongCount()]; //Длина сериализованной строки
            arr = Encoding.Default.GetBytes(hierarhy);   //Конвертируем в байты
            arr = aes.Encrypt(arr);                      // Шифруем
            FileProtocolReader.Write(arr, stream);
        }
 public void KeysExchange(TcpClient client, NetworkStream networkStream, DIFFIE_HELMAN aes)
 {
     //Отправляем свой ключ
     FileProtocolReader.Write(aes.PublicKey, networkStream);
     FileProtocolReader.Write(aes.IV, networkStream);
     while (client.Connected)
     {
         if (networkStream.DataAvailable)
         {
            byte[] client_key = null;
            FileProtocolReader.Read(ref client_key, networkStream);
            aes.CreateSecretKey(client_key);
            return;
         }
     }
 }