Ejemplo n.º 1
0
        public void SendFirstPackage(SocketEngine _socket)
        {
            Random _random = new Random(RandomPlus.RandomSeed);

            this.socketRxKey    = _random.Next(10000000, 100000000).ToString();
            this.socketChecksum = _random.Next(10000000, 100000000).ToString();

            JObject _json = new JObject();

            _json["code"] = this.Code;
            _json["time"] = DateTimePlus.DateTime2JSTime(DateTime.UtcNow).ToString();
            _json["num"]  = this.socketChecksum;
            _json["key"]  = this.socketRxKey;

            _socket.SendPackage(_json);
        }
Ejemplo n.º 2
0
        public bool ReceiveFirstPackage(JObject _json, SocketEngine _socket)
        {
            if (this.socketTxKey != "")
            {
                return(false);
            }

            if (!this.rsa.Verify(this.socketChecksum, _json["check"].Value <string>()))
            {
                this.socketTxKey = "";
                return(true);
            }
            this.socketTxKey = _json["key"].Value <string>();

            JObject _result = new JObject();

            _result["check"] = this.rsa.Sign(_json["num"].Value <string>());

            _socket.SendPackage(_result);
            _socket.Handshaked = true;
            return(true);
        }