pythondef cal_file_md5(file_path):
'''
计算渠道包(未签名)md5
:param file_path:
:return:
'''
try:
# with open(file_path, 'rb') as fp:
# data = fp.read()
# file_md5 = hashlib.md5(data).hexdigest()
# return file_md5
m = hashlib.md5()
with open(file_path, 'rb') as fp:
while True:
# 分块读取,一次20M(20*1024*1024)
data = fp.read(20971520)
if not data:
break
m.update(data)
file_md5 = m.hexdigest()
return file_md5
except Exception as e:
r_logger.loginfo('[渠道包md5计算错误]:' + file_path + str(e))
r_alert.alert_admin('[渠道包md5计算错误]:' + file_path + str(e))
return False
本文作者:曹子昂
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!