def stream(**kwargs):
    """Provides an :py:func:`open`-like interface to the streaming encryptor/decryptor classes.

    .. warning::
        Take care when decrypting framed messages with large frame length and large non-framed
        messages. In order to protect the authenticity of the encrypted data, no plaintext
        is returned until it has been authenticated. Because of this, potentially large amounts
        of data may be read into memory.  In the case of framed messages, the entire contents
        of each frame are read into memory and authenticated before returning any plaintext.
        In the case of non-framed messages, the entire message is read into memory and
        authenticated before returning any plaintext.  The authenticated plaintext is held in
        memory until it is requested.

    .. note::
        Consequently, keep the above decrypting consideration in mind when encrypting messages
        to ensure that issues are not encountered when decrypting those messages.

    .. code:: python

        >>> import aws_encryption_sdk
        >>> kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids=[
        ...     'arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222',
        ...     'arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
        ...  ])
        >>> plaintext_filename = 'my-secret-data.dat'
        >>> ciphertext_filename = 'my-encrypted-data.ct'
        >>> with open(plaintext_filename, 'rb') as pt_file, open(ciphertext_filename, 'wb') as ct_file:
        ...      with aws_encryption_sdk.stream(
        ...         mode='e',
        ...         source=pt_file,
        ...         key_provider=kms_key_provider
        ...     ) as encryptor:
        ...         for chunk in encryptor:
        ...              ct_file.write(chunk)
        >>> new_plaintext_filename = 'my-decrypted-data.dat'
        >>> with open(ciphertext_filename, 'rb') as ct_file, open(new_plaintext_filename, 'wb') as pt_file:
        ...     with aws_encryption_sdk.stream(
        ...         mode='d',
        ...         source=ct_file,
        ...         key_provider=kms_key_provider
        ...     ) as decryptor:
        ...         for chunk in decryptor:
        ...             pt_file.write(chunk)

    :param str mode: Type of streaming client to return (e/encrypt: encryptor, d/decrypt: decryptor)
    :param **kwargs: All other parameters provided are passed to the appropriate Streaming client
    :returns: Streaming Encryptor or Decryptor, as requested
    :rtype: :class:`aws_encryption_sdk.streaming_client.StreamEncryptor`
        or :class:`aws_encryption_sdk.streaming_client.StreamDecryptor`
    :raises ValueError: if supplied with an unsupported mode value
    """
    mode = kwargs.pop("mode")
    _stream_map = {"e": StreamEncryptor, "encrypt": StreamEncryptor, "d": StreamDecryptor, "decrypt": StreamDecryptor}
    try:
        return _stream_map[mode.lower()](**kwargs)
    except KeyError:
        raise ValueError("Unsupported mode: {}".format(mode))
def stream ( ** kwargs ) : mode = kwargs . pop ( "mode" ) _stream_map = { "e" : StreamEncryptor , "encrypt" : StreamEncryptor , "d" : StreamDecryptor , "decrypt" : StreamDecryptor } try : return _stream_map [ mode . lower ( ) ] ( ** kwargs ) except KeyError : raise ValueError ( "Unsupported mode: {}" . format ( mode ) )
Provides an :py:func:`open`-like interface to the streaming encryptor/decryptor classes.

    .. warning::
        Take care when decrypting framed messages with large frame length and large non-framed
        messages. In order to protect the authenticity of the encrypted data, no plaintext
        is returned until it has been authenticated. Because of this, potentially large amounts
        of data may be read into memory.  In the case of framed messages, the entire contents
        of each frame are read into memory and authenticated before returning any plaintext.
        In the case of non-framed messages, the entire message is read into memory and
        authenticated before returning any plaintext.  The authenticated plaintext is held in
        memory until it is requested.

    .. note::
        Consequently, keep the above decrypting consideration in mind when encrypting messages
        to ensure that issues are not encountered when decrypting those messages.

    .. code:: python

        >>> import aws_encryption_sdk
        >>> kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids=[
        ...     'arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222',
        ...     'arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
        ...  ])
        >>> plaintext_filename = 'my-secret-data.dat'
        >>> ciphertext_filename = 'my-encrypted-data.ct'
        >>> with open(plaintext_filename, 'rb') as pt_file, open(ciphertext_filename, 'wb') as ct_file:
        ...      with aws_encryption_sdk.stream(
        ...         mode='e',
        ...         source=pt_file,
        ...         key_provider=kms_key_provider
        ...     ) as encryptor:
        ...         for chunk in encryptor:
        ...              ct_file.write(chunk)
        >>> new_plaintext_filename = 'my-decrypted-data.dat'
        >>> with open(ciphertext_filename, 'rb') as ct_file, open(new_plaintext_filename, 'wb') as pt_file:
        ...     with aws_encryption_sdk.stream(
        ...         mode='d',
        ...         source=ct_file,
        ...         key_provider=kms_key_provider
        ...     ) as decryptor:
        ...         for chunk in decryptor:
        ...             pt_file.write(chunk)

    :param str mode: Type of streaming client to return (e/encrypt: encryptor, d/decrypt: decryptor)
    :param **kwargs: All other parameters provided are passed to the appropriate Streaming client
    :returns: Streaming Encryptor or Decryptor, as requested
    :rtype: :class:`aws_encryption_sdk.streaming_client.StreamEncryptor`
        or :class:`aws_encryption_sdk.streaming_client.StreamDecryptor`
    :raises ValueError: if supplied with an unsupported mode value