from pathlib import Path
import hashlib


def hash_dir(vocab_folder_path: Path) -> str:
    """
    Generate an MD5 digest from the contents of a directory

    :param vocab_folder_path: Path
    :returns MD5 digest
    """
    hash_obj = hashlib.sha256()
    for vocab_file in vocab_folder_path.glob('*.csv'):
        with vocab_file.open('rb') as fp:
            hash_obj.update(fp.read())
    return hash_obj.hexdigest()