PythonCRC-32CRC-32MPEG-2循环冗余检验_第1页
PythonCRC-32CRC-32MPEG-2循环冗余检验_第2页
PythonCRC-32CRC-32MPEG-2循环冗余检验_第3页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、PythonCRC-32CRC-32MPEG-2循环冗余检验参考:1. CRC(循环冗余校验)在线计算2. CRC32/MPEG23. python求crc32值的法4. 关于python实现CRC32的应和总结5. python crc32()函数和C+计算crc326. C# CRC32校验 之 CRC-32/MPEG-2算法crc.pyReverts bit order of the given numberArgs:for i in range(width):if (num i) &1 != 0:reflected |= 1 (width - 1 - i)return reflecte

2、ddef make_table(width):Create static sized CRC lookup table and initialize it with 0.initializer =(0 for _ in range(256)if width =8:return array.array(B, initializer)elif width =16:return array.array(Q, initializer)else:width (int): Number of bits of the polynomialpolynomial (int): CRC polynomialdef

3、 _init_(self, width, polynomial, initial_value, final_xor_value,input_reflected , result_reflected):self.width =widthself.msb_mask =0 x01 (self.width - 1)self.reflected_table =Nonedef _call_(self, value):Compute the CRC checksum with respect to the model parameters by usingself.table =self.calculate

4、_crc_table()crc =self.initial_valuefor cur_byte in value:if self.input_reflected:cur_byte =reflect(cur_byte, 8)# Update the MSB of the CRC value with the next input bytecrc =(crc (cur_byte (self.width - 8) &self.cast_mask# This MSB byte value is the index into the lookup tablecrc =(crc 8) &self.cast

5、_mask# XOR-ing remainder from the loopup tablecrc =crc self.reflected_tableindex# Final XBORreturn crc self.final_xor_valuefor divident in range(256):cur_byte =(divident (self.width - 8) &self.cast_maskcur_byte = self.polynomialelse:cur_byte =1reflected_divident =reflect(divident, 8)cur_byte = self.

6、polynomialelse:=(8, 0 x1d, 0 xff, 0 xff, False, False)crc8_cdma2000crc8_darccrc16_ccit_zerocrc16_arccrc16_cdma2000crc16_dds_110crc16_dect_rcrc16_dect_xcrc16_dnpcrc16_acrc16_kermitcrc16_modbuscrc16_x25crc16_xmodem=(16, 0 x1021, 0 x0000, 0 x0000, False, False)crc32crc32_d=(32, 0 xa833982b, 0 xffffffff

7、, 0 xffffffff, True, True)=(32, 0 x04c11db7, 0 xffffffff, 0 x00000000, False, False)=(32, 0 x04c11db7, 0 x00000000, 0 xffffffff, False, False)=(32, 0 x814141ab, 0 x00000000, 0 x00000000, False, False)=(32, 0 x04c11db7, 0 xffffffff, 0 x00000000, True, True)=(32, 0 x000000af, 0 x00000000, 0 x00000000, False, False)assert crc16_ccit_zero(bHello world!) = 0 x39dbassert crc16_x25(bHello world!) = 0 x8edbcrc_test.pybyte_length =len(tempData)for i in range(byte_

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论