Esempio n. 1
0
        public Dictionary <string, string> GetKeys()
        {
            var client = new TcpClient(ipAddress, 9000);
            var stream = client.GetStream();

            byte[] read()
            {
                byte[] bufferSize = new byte[4];
                stream.Read(bufferSize, 0, 4);

                byte[] data = new byte[BitConverter.ToInt32(bufferSize, 0)];
                stream.Read(data, 0, data.Length);
                return(data);
            };

            protector.ExchangeKey(read, (ReadOnlySpan <byte> data) => {
                stream.Write(BitConverter.GetBytes(data.Length));
                stream.Write(data);
            });

            return(JsonSerializer.Deserialize <Dictionary <string, string> >(protector.Decrypt(read())));
        }
 public void PrepareProtecting()
 {
     _protector.ExchangeKey(ReadRequest, SendData);
 }
Esempio n. 3
0
 public void PrepareProtecting()
 {
     protector.ExchangeKey(ReadResponse, SendData);
 }