from pathlib import Path


def extract_hash(hashfile: Path, name: str) -> str:
    """Return MD5 hash from file of name:MD5 hashes.

    :param hashfile:  Path, path to file containing name:MD5 pairs
    :param name:  str, name associated with hash
    """
    filehash = None
    with open(hashfile, "r") as hhandle:
        for line in [_.strip().split() for _ in hhandle if len(_.strip())]:
            if Path(line[1]).name == name:  # hash filename
                filehash = line[0]
    return str(filehash)