from typing import Tuple
import hashlib
import base64


def _calc_md5_(path, chunk_size=8192) -> Tuple[str, str]:
    """
     Base64 encoded MD5 hash of a file.
     Same as GCS metadata label "Hash (md5)"
    """
    with open(path, "rb") as f:
        file_hash = hashlib.md5()
        chunk = f.read(chunk_size)
        while chunk:
            file_hash.update(chunk)
            chunk = f.read(chunk_size)

        return base64.b64encode(file_hash.digest()).decode('utf-8'), file_hash.hexdigest()