示例#1
0
            internal static byte[] StringToByteArray(string hex, bool trimWhitespace = true)
            {
                if (trimWhitespace)
                {
                    hex = hex.Replace(" ", string.Empty);
                }
                int NumberChars = hex.Length;

                byte[] bytes = new byte[NumberChars / 2];
                for (int i = 0; i < NumberChars; i += 2)
                {
                    bytes[i / 2] = SysConv.ToByte(hex.Substring(i, 2), 16);
                }
                return(bytes);
            }
示例#2
0
            internal static string BitsToString(SysCll.BitArray bits)
            {
                int    i    = 1;
                string derp = string.Empty;

                foreach (object bit in bits)
                {
                    derp += SysConv.ToInt32(bit);
                    if (i % 8 == 0)
                    {
                        derp += " ";
                    }
                    i++;
                }
                return(derp.Trim());
            }