protected override void Decrypt(byte[] raw, int offset, int length) { if (!_crypt.Decrypt(raw, offset, length)) { Logger.LogWarning("Checksum failed for packet"); } }
public async Task ReadAsync() { try { while (true) { byte[] buffer = new byte[2]; int bytesRead = await _networkStream.ReadAsync(buffer, 0, 2); if (bytesRead == 0) { Log.Debug("Client closed connection"); Close(); return; } if (bytesRead != 2) { throw new Exception("Wrong package structure"); } short length = BitConverter.ToInt16(buffer, 0); buffer = new byte[length - 2]; bytesRead = await _networkStream.ReadAsync(buffer, 0, length - 2); if (bytesRead != length - 2) { throw new Exception("Wrong package structure"); } if (!_loginCrypt.Decrypt(ref buffer, 0, buffer.Length)) { throw new Exception($"Blowfish failed on {Address}. Please restart auth server."); } #pragma warning disable 4014 Task.Factory.StartNew(() => _packetHandler.Handle(new Packet(1, buffer), this)); #pragma warning restore 4014 } } catch (Exception ex) { Log.Error($"Error: {ex.Message}"); Close(); } }
private void OnReceiveCallback(IAsyncResult result) { NetStream.EndRead(result); byte[] buff = new byte[_buffer.Length]; _buffer.CopyTo(buff, 0); if (!_loginCrypt.Decrypt(ref buff, 0, buff.Length)) { Log.Error($"Blowfish failed on {Address}. Please restart auth server."); } else { PacketHandler.Handle(new Packet(1, buff), this); Read(); } }
public bool Decrypt(byte[] Bytes) { return(Crypt.Decrypt(Bytes)); }