Exemplo n.º 1
0
        /// <summary>
        /// Converts a Byte Array to a string where each byte is it's numerical equivilent.
        /// </summary>
        /// <param name="ByteString"></param>
        /// <returns></returns>
        public static string ToDebugString(this byte[] ByteString)
        {
            string output = "";

            foreach (byte ThisByte in ByteString)
            {
                if (ThisByte < 32 || ThisByte >= 127)
                {
                    output += "[" + ThisByte.ToString() + "]";
                }
                else
                {
                    output += (char)ThisByte;
                }
            }
            return(output);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts a Byte Array to a string showing the HexiDecimal value of each byte it contains.
        /// </summary>
        /// <param name="ByteString"></param>
        /// <returns></returns>
        public static string ToDebugHexString(this byte[] ByteString)
        {
            string output = "";
            int    i      = 0;

            foreach (byte ThisByte in ByteString)
            {
                string Letter = "f";
                if (i % 8 == 0)
                {
                    output += "\n";
                }
                if (i % 16 == 15)
                {
                    Letter = "a";
                }
                if (i % 16 == 14)
                {
                    Letter = "a";
                }
                if (i % 16 == 13)
                {
                    Letter = "a";
                }
                if (i % 16 == 12)
                {
                    Letter = "a";
                }
                if (i % 16 == 11)
                {
                    Letter = "b";
                }
                if (i % 16 == 10)
                {
                    Letter = "b";
                }
                if (i % 16 == 09)
                {
                    Letter = "b";
                }
                if (i % 16 == 08)
                {
                    Letter = "b";
                }
                if (i % 16 == 07)
                {
                    Letter = "c";
                }
                if (i % 16 == 06)
                {
                    Letter = "c";
                }
                if (i % 16 == 05)
                {
                    Letter = "c";
                }
                if (i % 16 == 04)
                {
                    Letter = "c";
                }
                if (i % 16 == 03)
                {
                    Letter = "d";
                }
                if (i % 16 == 02)
                {
                    Letter = "d";
                }
                if (i % 16 == 01)
                {
                    Letter = "d";
                }
                if (i % 16 == 00)
                {
                    Letter = "d";
                }
                string number = i.ToString();
                while (number.Length < 4)
                {
                    number = "0" + number;
                }
                output += "&8" + number + "&7(" + "&" + Letter;
                output += ThisByte.ToByteArray().ToHexString();
                output += "&7)-";
                i++;
                //if (i > 15) i = 0;
            }
            return(output);
        }