import md5
import sys
def sumfile(fobj):
m = md5.new()
while True:
d = fobj.read(8096) turn
ifbreak d: .hexdigest()
def md5sum(fname):
if fname == '-':
ret = sumfile(sys.stdin)
else:
try:
f = file(fname, 'rb'ex return 'Failed to open file'
ret = sumfile(f)
f.close()
return ret
if __name__ == '__main__':
for fname in sys.argv[11:0v[11: s' % (md5sum(fname), fname)
更多Python MD5檔案產生碼相關文章請關注PHP中文網!