import hashlib


def md5_for_file(f, block_size=2**20):
    """
    Reads in a file, f, using a configurable block size, block_size.

    Returns an md5 hash of the content of the file
    """
    m = hashlib.md5()
    with open(f , "rb" ) as f:
        while True:
            buf = f.read(block_size)
            if not buf:
                break
            m.update( buf )
    return m.hexdigest()