private byte[] ConstructPacket(BattlEyePacketType packetType, int sequenceNumber, string command)
{
string type;
switch (packetType)
{
case BattlEyePacketType.Login:
type = Helpers.Hex2Ascii("FF00");
break;
case BattlEyePacketType.Command:
type = Helpers.Hex2Ascii("FF01");
break;
case BattlEyePacketType.Acknowledge:
type = Helpers.Hex2Ascii("FF02");
break;
default:
return new byte[] { };
}
if (packetType != BattlEyePacketType.Acknowledge)
{
if (command != null) command = Encoding.GetEncoding(1252).GetString(Encoding.UTF8.GetBytes(command));
}
string count = Helpers.Bytes2String(new byte[] { (byte)sequenceNumber });
byte[] byteArray = new CRC32().ComputeHash(Helpers.String2Bytes(type + ((packetType != BattlEyePacketType.Command) ? "" : count) + command));
string hash = new string(Helpers.Hex2Ascii(BitConverter.ToString(byteArray).Replace("-", "")).ToCharArray().Reverse().ToArray());
string packet = "BE" + hash + type + ((packetType != BattlEyePacketType.Command) ? "" : count) + command;
return Helpers.String2Bytes(packet);
}