import hashlib
def checksum(path):
fp=open(path)
checksum=hashlib.md5()
while True:
buffer=fp.read(8192)
if not buffer:break
checksum.update(buffer)
fp.close()
checksum=checksum.digest()
return checksum
path='/opt/python/file01'
print checksum(path)
path2='/opt/python/file02'
if checksum(path)==checksum(path2):
print "true"
else:
print "different"
阅读(1427) | 评论(0) | 转发(0) |