import hashlib
import base64


def hash_file_data(filename, return_type="bytes"):
    """
    Takes any byte data and returns the SHA256 hash in base64.
    """
    filebytes = open(filename, "rb").read()
    h = hashlib.sha256()
    h.update(filebytes)
    if return_type == "bytes":
        return h.digest()
    elif return_type == "base64":
        return base64.b64encode(h.digest())