def _hash_data(hasher, data):
    """Generate hash of data using provided hash type.

    :param hasher: Hasher instance to use as a base for calculating hash
    :type hasher: cryptography.hazmat.primitives.hashes.Hash
    :param bytes data: Data to sign
    :returns: Hash of data
    :rtype: bytes
    """
    _hasher = hasher.copy()
    _hasher.update(data)
    return _hasher.finalize()
