private void ProcessAndShowInfoClient()
 {
     // 如果接收到 <EOF> 表示完成一次,否则继续将自己置于接收状态
     if (messageFromServer.ToString().IndexOf("<EOF>") > -1)
     {
         //解密SSL通道发送过来的密文并显示
         LogInfo(string.Format("接收到服务器消息:{0}", RijndaelProcessor.DecryptString(messageFromServer.ToString().Substring(0, messageFromServer.ToString().Length - 5), keyCreateRandom)));
         messageFromServer.Clear();
     }
 }
        private void btnSendTextToClient_Click(object sender, EventArgs e)
        {
            if (serverCommunicateSocket == null || !serverCommunicateSocket.Connected)
            {
                LogInfo("发送失败,客户端未连接");
                return;
            }
            //加密消息体
            string msg   = string.Format("{0}{1}", RijndaelProcessor.EncryptString(DateTime.Now.ToString() + "  " + txtSendTo.Text, key), "<EOF>");
            string input = RijndaelProcessor.DecryptString(msg.Substring(0, msg.Length - 5), key);

            byte[] msgBytes = EncodingInstance.Instance.GetBytes(msg);
            serverCommunicateSocket.BeginSend(msgBytes, 0, msgBytes.Length, SocketFlags.None, null, null);
            LogInfo(string.Format("发送 : {0}", msg));
        }
        private void ProcessAndShowInServer()
        {
            string msg = messageFromClient.ToString();

            // 如果接收到 <EOF> 表示完成一次,否则继续将自己置于接收状态
            if (msg.IndexOf("<EOF>") > -1)
            {
                // 如果客户端发送Key,则负责初始化Key
                if (msg.IndexOf("<KEY>") > -1)
                {
                    key = RASProcesser.RSADecrypt(pfxKey, msg.Substring(0, msg.Length - 10));
                    LogInfo(string.Format("接收到客户端密钥:{0}", key));
                }
                else
                {
                    //解密SSL通道发送过来的密文并显示
                    LogInfo(string.Format("接收到客户端消息:{0}", RijndaelProcessor.DecryptString(msg.Substring(0, msg.Length - 5), key)));
                }
                messageFromClient.Clear();
            }
        }