import base64


def encode_base64(input_bytes, urlsafe=False):
    """Encode bytes as a base64 string without any padding."""

    encode = base64.urlsafe_b64encode if urlsafe else base64.b64encode
    output_bytes = encode(input_bytes)
    output_string = output_bytes.decode("ascii")
    return output_string.rstrip(u"=")