private void send(string action, ApplicationIcon toSend) { toSend.id = AudioSession.getCode(toSend.id); string data = action + JSONManager.serialize(toSend); send(data); }
public static void sendServerInfo(IPEndPoint clientEP) { TcpClient server; try { server = new TcpClient(); server.Connect(clientEP); } catch (SocketException e) { Console.WriteLine("Unable to connect to server: " + e.Message); return; } NetworkStream ns = server.GetStream(); string serverInfo = JSONManager.serialize(Main.info); byte[] serverInfoBytes = Encoding.ASCII.GetBytes(serverInfo); ns.Write(serverInfoBytes, 0, serverInfoBytes.Length); Console.WriteLine("Sent Server Info to: " + clientEP.ToString()); ns.Close(); server.Close(); }
private void send(string action, AudioSession toSend) { toSend = toSend.toCodeId(); toSend.volume = (float)Math.Round(toSend.volume, 2); string data = action + JSONManager.serialize(toSend); send(data); }
private void send(string action, AudioSession[] toSend) { AudioSession[] finalSend = new AudioSession[toSend.Length]; for (int i = 0; i < toSend.Length; i++) { toSend[i].volume = (float)Math.Round(toSend[i].volume, 2); finalSend[i] = toSend[i].toCodeId(); } string data = action + JSONManager.serialize(finalSend); send(data); }
public static string getEncryptedMessage(string msg, RSAKeyValue key) { string[] segments = getSegments(msg); string[] encryptedSegments = new string[segments.Length]; for (int i = 0; i < segments.Length; i++) { encryptedSegments[i] = Convert.ToBase64String(RSAEncrypt(Encoding.UTF8.GetBytes(segments[i]), key)); } string JSON = JSONManager.serialize(encryptedSegments); return(JSON); }
public static string getPublicKey() { CspParameters param = new CspParameters(); param.KeyContainerName = "VC_RSA_KEY"; //Create a new instance of RSACryptoServiceProvider. using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048, param)) { string xmlKey = RSA.ToXmlString(false); RSAKeyValue key = XMLManager.deserialize <RSAKeyValue>(xmlKey); Console.WriteLine("MOD:" + Convert.FromBase64String(key.Modulus).Length *8); string jsonKey = JSONManager.serialize(key); return(jsonKey); } }