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)); } }
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(); }
public void WriteByte(byte value) { if (loginCrypt != null) { input[0] = value; loginCrypt.Encrypt(input, output, 1); BaseStream.WriteByte(output[0]); } else { BaseStream.WriteByte(value); } }
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(); }
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); }
protected override int Encrypt(byte[] raw, int offset, int length) { return(_crypt.Encrypt(raw, offset, length)); }