import hashlib


def obtain_file_hash(path, hash_algo="md5"):
    """Obtains the hash of a file using the specified hash algorithm
    """
    hash_algo = hashlib.sha256() if hash_algo=="sha256" else hashlib.md5()

    block_size = 65535

    with open(path, 'rb') as f:
        for chunk in iter(lambda: f.read(block_size),b''):
            hash_algo.update(chunk)

    return hash_algo.hexdigest()