Python实现md5
''' md5sum in Pythonex: import hashlib m = hashlib.md5('stunnel-4.48.tar.gz') m.digest() print m.hexdigest()'''try: from hashlib import md5 #Python2.5 or later versionexcept: from md5 import md5 #Python2.4 or before versionimport sysimport urllibdef sumfile(fobj): m = md5() while True: d = fobj.read() if not d: break m.update(d) del(d) return m.hexdigest()def sumstr(str): m = md5() m.update(str) return m.hexdigest()def md5sum(fname): try: f = urllib.urlopen(fname, 'rb') #f = open(fname, 'rb') except: return False ret = sumfile(f) f.close() return retres=md5sum('http://stunnel.cybermirror.org/stunnel-4.48.tar.gz')print res?