Calculating LRC in java
<p>I want to calculate LRC for the following message:</p>

<pre>
T = 0101 0100
P = 0101 0000
1 = 0011 0001
2 = 0011 0010


Starting with 0x00 as the initial byte.

0 XOR ‘T’:         0000 0000
0101 0100
Result, LRC =    0101 0100


LRC XOR ‘P’:    0101 0100
                        0101 0000
Result, LRC =    0000 0100


LRC XOR ‘1’:    0000 0100
                        0011 0001
Result, LRC =    0011 0101


LRC XOR ‘2’:    0011 0101
                        0011 0010
Result, LRC =    0000 0111</pre>

<p>The code i have tried so far is shown below:</p>

<pre><code>public class TexttoBinary {

private static final int maxBytes = 1;

public static int convert(char number) {

   // BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Type the number to parse: ");
    //int number = Integer.parseInt(in.readLine());
    int Bit;
    //char number = '1';
    //UInt8 i;
    String result = "";
    for (int i = maxBytes * 7; i &gt;=0; i--) {
        Bit = 1 &lt;&lt; i;
        if (number &gt;= Bit) {
            result += 1;
            //System.out.println(result);
            number -= Bit;
        } else {
            result += 0;
        }
    }
    System.out.println(result);
   return Integer.parseInt(result);
}
public static void main(String args[]){
    String msg ="TP12";
    char[] toCharArray = msg.toCharArray();
    char lrc=0;
    for(int i=0;i&lt;toCharArray.length;i++)
    lrc ^=convert(toCharArray[i]);
    System.out.println((byte)lrc);
}
</code></pre>

<p>}</p>

<p>The output i am getting is something different. What do i do now ?</p>
