BattleNET.Helpers.Hex2Ascii C# (CSharp) Method

Hex2Ascii() public static method

public static Hex2Ascii ( string hexString ) : string
hexString string
return string
        public static string Hex2Ascii(string hexString)
        {
            byte[] tmp;
            int j = 0;
            tmp = new byte[(hexString.Length)/2];
            for (int i = 0; i <= hexString.Length - 2; i += 2)
            {
                tmp[j] = (byte) Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), NumberStyles.HexNumber));

                j++;
            }
            return Bytes2String(tmp);
        }

Usage Example

Ejemplo n.º 1
0
        private EBattlEyeCommandResult SendAcknowledgePacket(string command)
        {
            try
            {
                if (!_socket.Connected)
                {
                    return(EBattlEyeCommandResult.NotConnected);
                }

                var    crc32 = new CRC32();
                string packet;
                string header = "BE";
                string hash   = crc32.ComputeHash(Helpers.String2Bytes(Helpers.Hex2Ascii("FF02") + command)).Aggregate <byte, string>(null,
                                                                                                                                      (current, b)
                                                                                                                                      =>
                                                                                                                                      current +
                                                                                                                                      b.ToString(
                                                                                                                                          "X2"));
                hash    = Helpers.Hex2Ascii(hash);
                hash    = new string(hash.ToCharArray().Reverse().ToArray());
                header += hash;
                packet  = header + Helpers.Hex2Ascii("FF02") + command;
                _socket.Send(Helpers.String2Bytes(packet));

                _commandSend = DateTime.Now;
            }
            catch
            {
                return(EBattlEyeCommandResult.Error);
            }

            return(EBattlEyeCommandResult.Success);
        }
All Usage Examples Of BattleNET.Helpers::Hex2Ascii