private int calculate8BitChecksum(String infoString){
  int len=infoString.length();
  if (((len + 1) / 2) != (len / 2)) {
    return -1;
  }
  int calculatedChecksum=0;
  for (int i=0; i < len; i+=2) {
    calculatedChecksum+=Integer.parseInt(infoString.substring(i,i + 2),16);
  }
  return (0xFF & (0x100 - (calculatedChecksum & 0xFF)));
}

private int calculate8BitChecksum ( String infoString ) { int len = infoString . length ( ) ; if ( ( ( len + 1 ) / 2 ) != ( len / 2 ) ) { return - 1 ; } int calculatedChecksum = 0 ; for ( int i = 0 ; i < len ; i += 2 ) { calculatedChecksum += Integer . parseInt ( infoString . substring ( i , i + 2 ) , 16 ) ; } return ( 0xFF & ( 0x100 - ( calculatedChecksum & 0xFF ) ) ) ; }
calculates an 8 - bit checksum value from a string which uses sequential pairs of ascii characters to encode the hexadecimal values of a sequence of bytes . < p > when used to calculate the checksum of a record in i8hex or similar format , the infostring parameter is expected to include only those characters which are used for calculation of the checksum . the " record mark " at the beginning of a record should not be included in the infostring . similarly , the checksum at the end of a record should generally not be included in the infostring . < p > an example infostring value might be : 020000040010 < p > in case of an invalid infostring , the returned checksum is - 1 . < p > if using this method to verify the checksum of a record , the infostring should include the record checksum characters . then the invoking method may check for a non - zero return value to indicate a checksum error .
