import typing
import pathlib
import hashlib
from pathlib import Path


def md5(p: typing.Union[pathlib.Path, str], bufsize: int = 32768) -> str:
    """
    Compute md5 sum of the content of a file.
    """
    hash_md5 = hashlib.md5()
    with Path(p).open('rb') as fp:
        for chunk in iter(lambda: fp.read(bufsize), b''):
            hash_md5.update(chunk)
    return hash_md5.hexdigest()