import hashlib


def hash_generator(file, hash_algorithm):
    """
    Generate a hash for a file based on a given hash algorithm

    Parameters
    ----------
    file : bytes
        File to be ran through the hash algorithm
    hash_algorithm : str
        Hash algorithm to use

    Returns
    -------
    String of the file hash generated by the given hash algorithm.
    """
    h = hashlib.new(hash_algorithm)
    h.update(file)
    return h.hexdigest()