import base64


def b64encode(value, pretty=False):
    """
    Base64 encode for string.

    Plazy version: 0.1.3+

    Parameters
    ----------
    value : str
        String to encode.
    pretty : bool, optional
        Pretty string or not (remove "=" character). Default: False

    Keyword Arguments
    -----------------

    Returns
    -------
    out : str
        Encoded string.

    Examples
    --------

    .. code-block:: python
        :linenos:
        :emphasize-lines: 4,5

        import plazy

        if __name__ == "__main__":
            encoded_val = plazy.b64encode('plazy') # cGxhenk=
            encoded_val = plazy.b64encode('plazy', pretty=True) # cGxhenk => Note: this string cannot be decoded!
            original_val = plazy.b64decode('cGxhenk=') # plazy

    See Also
    --------
    b64decode
    """
    res = str(base64.b64encode(value.encode()).decode("utf-8"))
    if pretty:
        res = res.replace("=", "")
    return res