import hashlib


def get_sha256_hash(key, size=None):
    """
    Provide a SHA256 hash based on the supplied key values.

    :param key: An iterable of key values.
    :param size: The size of the returned hash.  Defaults to full hash.  If
      size provided is greater than the hash size the full hash is returned.

    :returns: a SHA256 hash for the key values supplied.
    """
    partition_hash = hashlib.sha256()
    for part in key:
        partition_hash.update(str(part).encode('utf-8'))
    sha256_hash = partition_hash.hexdigest()
    if not size or size > len(sha256_hash):
        size = len(sha256_hash)
    return sha256_hash[:size]