本文实例讲述了python求crc32值的方法。分享给大家供大家参考。具体实现方法如下:
要想求CRC值,前面要import binascii
binascii.crc32(v) 求出了v的crc32值,这是一个long型,形如-1456387L,把这个值&0xffffffff得到的值形如48a213L的形式。
然后把这个值用16进制表示出来、
具体代码如下:
def _crc32(self, v):
"""
Generates the crc32 hash of the v.
@return: str, the str value for the crc32 of the v
"""
return '0x%x' % (binascii.crc32(v) & 0xffffffff) #取crc32的八位数据 %x返回16进制
希望本文所述对大家的Python程序设计有所帮助。
python实现计算资源图标crc值的方法
本文实例讲述了python实现计算资源图标crc值的方法,分享给大家供大家参考。具体方法如下:实现该功能的关键在于解析资源信息,找到icon的数据,然
python实现上传样本到virustotal并查询扫描信息的方法
本文实例讲述了python实现上传样本到virustotal并查询扫描信息的方法。分享给大家供大家参考。具体方法如下:importsimplejsonimporturllibimporturllib2importosMD5="5
python写xml文件的操作实例
本文实例讲述了python写xml文件的操作的方法,分享给大家供大家参考。具体方法如下:要生成的xml文件格式如下:xmlversion="1.0"!--Simplexmldocument__chapter8--bo