public static PRUdpPacket Decode(byte[] bytes)
        {
            var    hex = bytes.ToHex();
            var    str = hex.Substring(4, 2);
            string sessionid = "", sig = "", seqnum = "", connsig = "", fragid = "", payload = "";
            var    typenflags = str.FromHexToBits();
            var    checksum   = hex.Substring(hex.Length - 8);

            int[] data = new int[typenflags.Count];
            for (int i = 0; i < typenflags.Count; i++)
            {
                if ((bool)typenflags[i])
                {
                    data[i] = 1;
                }
                else
                {
                    data[i] = 0;
                }
            }
            var flags  = Convert.ToString(data[0]) + Convert.ToString(data[1]) + Convert.ToString(data[2]) + Convert.ToString(data[3]) + Convert.ToString(data[4]);
            var type   = Convert.ToString(data[5]) + Convert.ToString(data[6]) + Convert.ToString(data[7]);
            var packet = new PRUdpPacket();

            packet.Type  = (PacketTypes)Convert.ToInt32(type, 2);
            packet.Flags = PFlags.ParseFlags(flags);
            if (packet.Type == PacketTypes.SYN || packet.Type == PacketTypes.CONNECT)
            {
                sessionid = hex.Substring(6, 2);
                sig       = hex.Substring(8, 8);
                seqnum    = hex.Substring(16, 4);
                connsig   = hex.Substring(20, 8);

                /*var f = connsig.Substring(0, 2);
                 * var ff = connsig.Substring(2, 2);
                 * var fff = connsig.Substring(4, 2);
                 * var ffff = connsig.Substring(6, 2);
                 * connsig = ffff + fff + ff + f;*/
            }
            else if (packet.Type == PacketTypes.DATA)
            {
                sessionid         = hex.Substring(6, 2);
                sig               = hex.Substring(8, 8);
                seqnum            = hex.Substring(16, 4);
                fragid            = hex.Substring(20, 2);
                payload           = PythonScript.DecompressPacketPayload(RC4.Decrypt(Encoding.ASCII.GetBytes("CD&ML"), hex.Substring(22, hex.Length - 30).FromHex()).ToHex().Substring(2)).Result;
                packet.RMCPayload = RMCPayload.Decode(payload);
            }
            else
            {
                sessionid = hex.Substring(6, 2);
                seqnum    = hex.Substring(8, 4);
            }
            packet.SessionId           = sessionid;
            packet.Signature           = sig;
            packet.Checksum            = checksum;
            packet.ConnectionSignature = connsig;
            packet.Payload             = payload;
            return(packet);
        }