public static ushort Update( ushort crc, byte[] data, long data_len )
{
uint i;
bool bit;
byte c;
for ( long idx = 0; idx < data_len; ++idx ) {
c = data[idx];
for ( i = 0x80; i > 0; i >>= 1 ) {
bit = ( crc & 0x8000 ) != 0;
if ( ( c & i ) != 0 ) {
bit = !bit;
}
crc <<= 1;
if ( bit ) {
crc ^= 0x1021;
}
}
crc &= 0xffff;
}
return (ushort)( crc & 0xffff );
}