#!/usr/bin/env python
# -*- coding: utf-8 -*-
import hashlib
import os
#简单的测试一个字符串的MD5值
def GetStrMd5(src):
m = hashlib.md5()
m.update(src.encode('UTF-8'))
return m.hexdigest()
#大文件的MD5值
def GetFileMd5(filename):
if not os.path.isfile(filename):
return
myhash = hashlib.md5()
f = open(filename,'rb')
while True:
b = f.read(8096)
if not b :
break
myhash.update(b)
f.close()
return myhash.hexdigest()
暂无评论