#NEWLINE# def str_encode( value , encoder = 'base64' ) : #NEWLINE# #INDENT# "\n    .. versionadded:: 2014.7.0\n\n    value\n        The value to be encoded.\n\n    encoder : base64\n        The encoder to use on the subsequent string.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' random.str_encode 'I am a new string' base64\n    " #NEWLINE# try : #NEWLINE# #INDENT# out = value . encode ( encoder ) #NEWLINE# #UNINDENT# except LookupError : #NEWLINE# #INDENT# raise SaltInvocationError ( 'You must specify a valid encoder' ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# raise SaltInvocationError ( 'Value must be an encode-able string' ) #NEWLINE# #UNINDENT# return encoder