Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Exchange Data (Secure channel) useroption 1
- // Send data...
- int money = 42;
- byte[] encryptedData = symmetricsSI.Encrypt(BitConverter.GetBytes(money));
- Console.Write("Sending data... ");
- msg = protocol.Make(ProtocolSICmdType.USER_OPTION_1, encryptedData);
- netStream.Write(msg, 0, msg.Length);
- Console.WriteLine("ok.");
- Console.WriteLine("Encrypted data sent (HEX): {0}", ProtocolSI.ToHexString(encryptedData));
- // Receive answer from server
- Console.Write("waiting for conversion... ");
- netStream.Read(protocol.Buffer, 0, protocol.Buffer.Length);
- byte[] encryptedConvertion = protocol.GetData();
- int convertion = BitConverter.ToInt32(symmetricsSI.Decrypt(encryptedConvertion), 0);
- Console.WriteLine("\nconvertion : " + convertion);
- Console.WriteLine("ok.");
- #endregion
- Console.WriteLine(SEPARATOR);
- #region Exchange Data (Secure channel) useroption2
- // Send data...
- money = 4200;
- encryptedData = symmetricsSI.Encrypt(BitConverter.GetBytes(money));
- Console.Write("Sending data... ");
- msg = protocol.Make(ProtocolSICmdType.USER_OPTION_2, encryptedData);
- netStream.Write(msg, 0, msg.Length);
- Console.WriteLine("ok.");
- Console.WriteLine("Encrypted data sent (HEX): {0}", ProtocolSI.ToHexString(encryptedData));
- // Receive answer from server
- Console.Write("waiting for conversion... ");
- netStream.Read(protocol.Buffer, 0, protocol.Buffer.Length);
- encryptedConvertion = protocol.GetData();
- convertion = BitConverter.ToInt32(symmetricsSI.Decrypt(encryptedConvertion), 0);
- Console.WriteLine("\nconvertion : " + convertion);
- Console.WriteLine("ok.");
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement