2 """User wrapper for md5 builtin object"""
4 __all__ = ['md5wrapper']
7 if sys.version < '2.5':
10 from hashlib import md5
13 def __init__(self, init=None):
19 def update(self, data):
20 self._md5.update(data)
23 return self._md5.digest()
27 return "%02x"*len(str) % tuple(map(ord, str))
28 # This nice was suggested by Guido
31 if type(f) == type(''): # If f is string - use it as file's name
34 infile = f # else assume it is file or file-like object
38 buf = infile.read(16*1024)
43 if type(f) == type(''): # If f was opened - close it
46 if __name__ == "__main__":
47 print "This must print exactly the string"
48 print "Test: 900150983cd24fb0d6963f7d28e17f72"
49 print "Test:", md5wrapper("abc")