import hashlib


def file_md5(fpath):
    """Return the MD5 digest for the given file"""
    with open(fpath,'rb') as f:
        m = hashlib.md5()
        while True:
            s = f.read(4096)
            if not s:
                break
            m.update(s)
        return m.hexdigest()