Functional Weave
Code in Python

encoding.base64@1.0.0

impl/python/base64_url_encode.py

303 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from typing import Sequence

from .encoding_base64_base64_encode import base64_encode  ← base64Encode, another function of this group · built into the same file, even by a slim install


def base64_url_encode(bytes: Sequence[int]) -> str:
    """Bytes as base64url (RFC 4648 section 5) without padding, as JWTs use it."""
    return base64_encode(bytes).rstrip("=").replace("+", "-").replace("/", "_")