def sumfile(fobj):
    '''Returns an md5 hash for an object with read() method.'''
    m = md5.new()
    while True:
        d = fobj.read(8096)
        if not d:
            break
        m.update(d)
    return m.hexdigest()
Returns an md5 hash for an object with read() method.
recipes/Python/266486_Simple_md5_sum_utility/recipe-266486.py