Urlsafe Base64 for Python
A simple module for encoding without padding, fixing Python standard library's flaws.
Replaces the standard library's base64.urlsafe_b64encode and base64.urlsafe_b64decode with a cleaner implementation that returns strings instead of bytes and avoids unnecessary padding.
Features
- Urlsafe: Uses only characters that are safe for URLs and filenames
- No padding: Removes trailing
=characters for a cleaner, actually urlsafe output - String output: Returns Base64 as str instead of bytes
- Fast: Based on Python stdlib, with constant-time padding restoration
Installation
pip install base64url
Or for your project using UV:
uv add base64url
Usage
import base64url
text = base64url.enc(bytes(4)) # Returns "AAAAAA"
data = base64url.dec(text) # Recovers the bytes
enc(data: bytes) -> str
Encode bytes to a urlsafe string without padding.
dec(s: str, *, validate=True) -> bytes
Decode standard or urlsafe Base64 into bytes. Padding optional. Raises binascii.Error (ValueError) on invalid input. Set validate=False to silently ignore unknown characters (Python base64 default behavior).
enc_lines(data: bytes, length=76, sep="\n") -> str
Encode with newlines inserted every length characters. Does not add a newline at the end.
dec_lines(s: str) -> bytes
Decode formatted input, ignoring whitespace. Raises binascii.Error on invalid characters.
Metadata
Release files for base64url 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| base64url-1.1.1.tar.gz | 3.6 kB | Without provenance | Details for base64url-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| base64url-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for base64url-1.1.1-py3-none-any.whl |
Total release size: 6.3 kB
Release files / base64url-1.1.1.tar.gz
| Download URL | base64url-1.1.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7accac6a116299bebbd1fbb83b8a3b6192ac5bee5bc53d88e7fb79f99d29e6b
|
|
BLAKE2b-256 checksum How to use checksums |
17d59d749f7b55f734be709c1c78e7100abeee4559b4139a782df638f4592298
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / base64url-1.1.1-py3-none-any.whl
| Download URL | base64url-1.1.1-py3-none-any.whl |
|---|---|
| Size | 2.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
455ff8619739fdd118e01ef5990e821b272fb29ad7e8b27a08fa21c1bd6ccdd7
|
|
BLAKE2b-256 checksum How to use checksums |
05be4041fd20bcedf32755427bc409f058118d979c8381ce0008aa89776fac73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for base64url 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.