Ejemplo n.º 1
0
        public int Read(byte[] buffer, int offset, int count)
        {
            if (loginCrypt != null)
            {
                for (var i = 0; i < count; i++)
                {
                    input[0] = (byte)BaseStream.ReadByte();
                    loginCrypt.Encrypt(input, output, 1);
                    buffer[i + offset] = output[0];
                }

                return(count);
            }
            else
            {
                return(BaseStream.Read(buffer, offset, count));
            }
        }
Ejemplo n.º 2
0
        public void Send(Packet p)
        {
            byte[] data = p.GetBuffer();
            data = _loginCrypt.Encrypt(data, 0, data.Length);
            List <byte> array = new List <byte>();

            array.AddRange(BitConverter.GetBytes((short)(data.Length + 2)));
            array.AddRange(data);
            NetStream.Write(array.ToArray(), 0, array.Count);
            //Log.Info($"Receive :\r\n{L2Buffer.ToString(array.ToArray())}");
            NetStream.Flush();
        }
Ejemplo n.º 3
0
        public void WriteByte(byte value)
        {
            if (loginCrypt != null)
            {
                input[0] = value;
                loginCrypt.Encrypt(input, output, 1);

                BaseStream.WriteByte(output[0]);
            }
            else
            {
                BaseStream.WriteByte(value);
            }
        }
Ejemplo n.º 4
0
        public async Task SendAsync(Packet p)
        {
            byte[] data = p.GetBuffer();
            data = _loginCrypt.Encrypt(data, 0, data.Length);

            byte[] lengthBytes = BitConverter.GetBytes((short)(data.Length + 2));
            byte[] message     = new byte[data.Length + 2];

            lengthBytes.CopyTo(message, 0);
            data.CopyTo(message, 2);

            await NetStream.WriteAsync(message, 0, message.Length);

            await NetStream.FlushAsync();
        }
Ejemplo n.º 5
0
 public void SendPacket(SendablePacket Packet)
 {
     Packet.write();
     byte[] PacketBytes = Packet.GetBytes();
     using (Packet)
     {
         PacketBytes = Crypt.Encrypt(PacketBytes);
         using (MemoryStream s = new MemoryStream())
         {
             byte[] PacketLength = BitConverter.GetBytes((short)(PacketBytes.Length + 2));
             s.Write(PacketLength, 0, PacketLength.Length);
             s.Write(PacketBytes, 0, PacketBytes.Length);
             PacketBytes = s.ToArray();
         }
     }
     _Conn.Send(PacketBytes);
 }
Ejemplo n.º 6
0
 protected override int Encrypt(byte[] raw, int offset, int length)
 {
     return(_crypt.Encrypt(raw, offset, length));
 }