title: How to calculate checksum in CRC8 from boolean array
body: <p>I have boolean array with some networks packet and need to calculate CRC8 but something goes wrong and I really don't know what.</p>
  
  <p>CRC8 Key:
  100000111</p>
  
  <p>input:
  1111111111111111111111111111111100000000</p>
  
  <p>output:
  1000001000001000001000001000001011011000</p>
  
  <p>should :
  1111111111111111111111111111111110111000</p>
  
  <pre><code>private static boolean[][] CRC8(boolean[][] packets, boolean[] CRC8Key) 
  {
      boolean[]checksum=new boolean[CRC8Key.length-1];
      for(int i =0;i&lt;packets.length;i++)
      {
          checksum=calculateChecksum(packets[i],CRC8Key);
          packets[i]=addCheckssumToPacket(packets[i],checksum);       
      }
      return packets;
  }
  
  private static boolean[] addCheckssumToPacket(boolean[] singlePacket,boolean[] checksum) {
      for(int i=0;i&lt;checksum.length;i++)
      {
          singlePacket[singlePacket.length-(checksum.length-i)]=checksum[i];
      }
  
      return singlePacket;
  }
  
  protected static boolean[] calculateChecksum(boolean[] singlePacket, boolean[] CRC8Key) 
  {       
      for (int i=0;i&lt;32;i++)
      {
          if(singlePacket[i])
          {
              xorPartOfPacketWithKey(singlePacket, CRC8Key, i);
              System.out.println();
          }
      }
      return checksumm(singlePacket);
  }
  
  protected static boolean[] xorPartOfPacketWithKey(boolean[] singlePacket,boolean[] CRC8Key, int beginOfXor) 
  {
      int k=0;
      for(int i=beginOfXor;i&lt;beginOfXor+(CRC8Key.length);i++)
      {   
          singlePacket[i]=xor(singlePacket[i],CRC8Key[i-beginOfXor]);         
          k++;
      }
      return singlePacket;
  }
  
  protected static boolean[] checksumm(boolean[] singlePacket) {
      boolean[]checksum=new boolean[8];
      for (int i=0;i&lt;8;i++)
      {
          checksum[i]=singlePacket[singlePacket.length-(8-i)];
      }
      return checksum;
  }
  </code></pre>