def str_encode(value, encoder='base64'):
    '''
    .. versionadded:: 2014.7.0

    value
        The value to be encoded.

    encoder : base64
        The encoder to use on the subsequent string.

    CLI Example:

    .. code-block:: bash

        salt '*' random.str_encode 'I am a new string' base64
    '''
    try:
        out = value.encode(encoder)
    except LookupError:
        raise SaltInvocationError('You must specify a valid encoder')
    except __HOLE__:
        raise SaltInvocationError('Value must be an encode-able string')

    return out
dataset/ETHPy150Open saltstack/salt/salt/modules/mod_random.py/str_encode