private function calculateChecksum($data) {
    if (strlen($data) % 2) {
      $data .= "\x00";
    }

    $bit = unpack('n*', $data);
    $sum = array_sum($bit);

    while ($sum >> 16) {
      $sum = ($sum >> 16) + ($sum & 0xffff);
    }

    return pack('n*', ~$sum);
  }
private function calculateChecksum($data) {
    if (strlen($data) % 2) {
      $data .= "\x00";
    }

    $bit = unpack('n*', $data);
    $sum = array_sum($bit);

    while ($sum >> 16) {
      $sum = ($sum >> 16) + ($sum & 0xffff);
    }

    return pack('n*', ~$sum);
  }
private function calculateChecksum ( $ data ) { if ( strlen ( $ data ) % 2 ) { $ data .= "\x00" ; } $ bit = unpack ( 'n*' , $ data ) ; $ sum = array_sum ( $ bit ) ; while ( $ sum >> 16 ) { $ sum = ( $ sum >> 16 ) + ( $ sum & 0xffff ) ; } return pack ( 'n*' , ~ $ sum ) ; }
Calculate a checksum.

@param string $data
Data for which checksum will be calculated.

@return string
Binary string checksum of $data.
Calculate a checksum .