def str_encode(value, encoder='base64'):
    try:
        out = value.encode(encoder)
    except LookupError:
        raise SaltInvocationError('You must specify a valid encoder')
    except AttributeError:
        raise SaltInvocationError('Value must be an encode-able string')

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