Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #region Exchange Data (Secure channel) useroption 1
  2. // Send data...
  3. int money = 42;
  4. byte[] encryptedData = symmetricsSI.Encrypt(BitConverter.GetBytes(money));
  5. Console.Write("Sending data... ");
  6. msg = protocol.Make(ProtocolSICmdType.USER_OPTION_1, encryptedData);
  7. netStream.Write(msg, 0, msg.Length);
  8. Console.WriteLine("ok.");
  9.  
  10. Console.WriteLine("Encrypted data sent (HEX): {0}", ProtocolSI.ToHexString(encryptedData));
  11.  
  12. // Receive answer from server
  13. Console.Write("waiting for conversion... ");
  14. netStream.Read(protocol.Buffer, 0, protocol.Buffer.Length);
  15. byte[] encryptedConvertion = protocol.GetData();
  16. int convertion = BitConverter.ToInt32(symmetricsSI.Decrypt(encryptedConvertion), 0);
  17. Console.WriteLine("\nconvertion : " + convertion);
  18. Console.WriteLine("ok.");
  19. #endregion
  20.  
  21. Console.WriteLine(SEPARATOR);
  22.  
  23. #region Exchange Data (Secure channel) useroption2
  24. // Send data...
  25. money = 4200;
  26. encryptedData = symmetricsSI.Encrypt(BitConverter.GetBytes(money));
  27. Console.Write("Sending data... ");
  28. msg = protocol.Make(ProtocolSICmdType.USER_OPTION_2, encryptedData);
  29. netStream.Write(msg, 0, msg.Length);
  30. Console.WriteLine("ok.");
  31.  
  32. Console.WriteLine("Encrypted data sent (HEX): {0}", ProtocolSI.ToHexString(encryptedData));
  33.  
  34. // Receive answer from server
  35. Console.Write("waiting for conversion... ");
  36. netStream.Read(protocol.Buffer, 0, protocol.Buffer.Length);
  37. encryptedConvertion = protocol.GetData();
  38. convertion = BitConverter.ToInt32(symmetricsSI.Decrypt(encryptedConvertion), 0);
  39. Console.WriteLine("\nconvertion : " + convertion);
  40. Console.WriteLine("ok.");
  41. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement