src/Util/Checksum.php
protected static function crc16($binaryString)
    {
        $crc = 0x0000;
        $polynomial = 0x1021;

        foreach (str_split($binaryString) as $byte) {
            $byte = ord($byte);

            for ($i = 0; $i < 8; $i++) {
                $bit = (($byte >> (7 - $i) & 1) == 1);
                $c15 = (($crc >> 15 & 1) == 1);
                $crc <<= 1;
                if ($c15 ^ $bit) $crc ^= $polynomial;
            }
        }

        return $crc & 0xffff;
    }
protected static function crc16($binaryString)
    {
        $crc = 0x0000;
        $polynomial = 0x1021;

        foreach (str_split($binaryString) as $byte) {
            $byte = ord($byte);

            for ($i = 0; $i < 8; $i++) {
                $bit = (($byte >> (7 - $i) & 1) == 1);
                $c15 = (($crc >> 15 & 1) == 1);
                $crc <<= 1;
                if ($c15 ^ $bit) $crc ^= $polynomial;
            }
        }

        return $crc & 0xffff;
    }
Returns the crc16 checksum of $binaryString

Ported from Java implementation at: http://introcs.cs.princeton.edu/java/61data/CRC16CCITT.java.html

Initial value changed to 0x0000 to match Stellar configuration.

@param $binaryString
@return int (4-byte checksum)