- 论坛徽章:
- 0
|
代码如下,为何我这段代码计算出的来的文件CRC32 跟别人工具计算出来的不一样呢?
别人算出来都是8位的,我的是10位...请教下错在哪里....
from ctypes import *
import zlib
def getFileCRC(_path):
try:
blocksize = 1024 * 64
f = open(_path,"rb")
str = f.read(blocksize)
crc = 0
while(len(str) != 0):
crc = zlib.crc32(str, crc)
str = f.read(blocksize)
f.close()
except:
klog.error("get file crc error!")
return 0
return c_uint(crc).value
_path=('e:\\Desktop\\test\\search.py')
print getFileCRC(_path) |
|
|