public static void Main()
Console.WriteLine("Input: " + input);
Console.WriteLine("Output: " + Encoding.ASCII.GetString(CalcLRC(Encoding.ASCII.GetBytes(input))));
private static byte[] CalcLRC(byte[] cmnd)
int i, j, bSize = cmnd.Length;
uint lrc, high, low, CR, LF;
byte[] bytes = new byte[((bSize) + 4)];
for (i = 0; i < cmnd.Length; i++)
lrc = lrc + (uint)cmnd[i];
lrc = lrc - (uint)(256 * Math.Floor((double)lrc / 256));
lrc = lrc - (uint)(256 * Math.Floor((double)lrc / 256));
temp = lrc.ToString("X");
bytes[(bSize)] = (byte)high;
bytes[(bSize + 1)] = (byte)low;
bytes[(bSize + 2)] = (byte)CR;
bytes[(bSize + 3)] = (byte)LF;