def hash_file ( fileobj ) : hasher = hashlib . md5 ( ) buf = fileobj . read ( 65536 ) while len ( buf ) > 0 : hasher . update ( buf ) buf = fileobj . read ( 65536 ) return hasher . hexdigest ( )
python file hash md5
: param fileobj : a file object : return : a hash of the file content
def hash_file(fileobj):
    """
    :param fileobj: a file object
    :return: a hash of the file content
    """
    hasher = hashlib.md5()
    buf = fileobj.read(65536)
    while len(buf) > 0:
        hasher.update(buf)
        buf = fileobj.read(65536)
    return hasher.hexdigest()