var numOfBytes = (int)Math.Ceiling(line.Length / 8m); var linebytes = new byte[numOfBytes]; var lenth = 8; for (int j = 1; j <= numOfBytes; j++) { var startIndex = line.Length - 8 * j; if (!int.TryParse(line, out lenth)) { Console.WriteLine("{0} is non parsable character at the end of the string", line); } if (startIndex < 0) { lenth = 8 + startIndex; startIndex = 0; } string sub = line.Substring(startIndex, lenth); linebytes[numOfBytes - j] = Convert.ToByte(sub, 2);
StringBuilder hexString = new StringBuilder(); for (int i = 0; i < byteArray.Length; ++i) { hexString.Append(string.Format("{0:X2}", byteArray[i])); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)