def METHOD_NAME(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
    """
    if isinstance(value, str):
        value = value.encode(__salt_system_encoding__)
    if encoder == "base64":
        try:
            out = base64.b64encode(value)
            out = out.decode(__salt_system_encoding__)
        except TypeError:
            raise SaltInvocationError("Value must be an encode-able string")
    else:
        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