计算CRC校验值(CRC16和CRC32)(网络传输检验)

CRC有非常多的模式,我没有全部都做,目前支持

  • CRC16-Modbus
  • CRC16-X25
  • CRC32

使用方法

auto data = QByteArray::fromHex( "01 02 03 04 05" );
auto crc16ForModbus = JQChecksum::crc16ForModbus( data );
auto crc16ForX25 = JQChecksum::crc16ForX25( data );
auto crc32 = JQChecksum::crc32( data );

qDebug() << "crc16ForModbus:"   << crc16ForModbus   << QString::number( crc16ForModbus, 16 );
qDebug() << "crc16ForX25:"      << crc16ForX25      << QString::number( crc16ForX25, 16 );
qDebug() << "crc32:"            << crc32            << QString::number( crc32, 16 );

GitHub地址

https://github.com/188080501/JQChecksum

http://blog.csdn.net/wsj18808050/article/details/51907988

 

CRC的详细原理图:

http://www.cnblogs.com/esestt/archive/2007/08/09/848856.html

http://blog.csdn.net/liyuanbhu/article/details/7882789

posted @ 2016-10-30 05:29  findumars  Views(2908)  Comments(0Edit  收藏  举报