예제 #1
0
파일: Session.cs 프로젝트: xnum/maplelib2
        /// <summary>
        /// Encrypts the packet then send it to the client.
        /// </summary>
        /// <param name="input">The byte array to be sent.</param>
        public void SendPacket(byte[] input)
        {
            byte[] cryptData = input;
            byte[] sendData  = new byte[cryptData.Length + 4];
            byte[] header    = _type == SessionType.SERVER_TO_CLIENT ? _SIV.getHeaderToClient(cryptData.Length) : _SIV.getHeaderToServer(cryptData.Length);

            MapleCustomEncryption.Encrypt(cryptData);
            _SIV.crypt(cryptData);

            System.Buffer.BlockCopy(header, 0, sendData, 0, 4);
            System.Buffer.BlockCopy(cryptData, 0, sendData, 4, cryptData.Length);
            SendRawPacket(sendData);
        }
예제 #2
0
        /// <summary>
        /// Encrypts the packet then send it to the client.
        /// </summary>
        /// <param name="packet">The PacketWrtier object to be sent.</param>

        /// <summary>
        /// Encrypts the packet then send it to the client.
        /// </summary>
        /// <param name="input">The byte array to be sent.</param>
        public void SendPacket(byte[] input)
        {
            if (!Connected || !_socket.Connected)
            {
                return;
            }
            byte[] cryptData = input;
            byte[] sendData  = new byte[cryptData.Length + 4];
            byte[] header    = _type == SessionType.SERVER_TO_CLIENT ? _SIV.getHeaderToClient(cryptData.Length) : _SIV.getHeaderToServer(cryptData.Length);

            SIV.Encrypt(cryptData);

            System.Buffer.BlockCopy(header, 0, sendData, 0, 4);
            System.Buffer.BlockCopy(cryptData, 0, sendData, 4, cryptData.Length);
            SendRawPacket(sendData);
        }