diff --git a/README.md b/README.md index 916b5ad..5a16bcb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# URL-safe Base64 for Python +# Urlsafe Base64 for Python A simple module for encoding without padding, fixing Python standard library's flaws. @@ -7,8 +7,8 @@ Replaces the standard library's `base64.urlsafe_b64encode` and `base64.urlsafe_b ## Features - **Urlsafe**: Uses only characters that are safe for URLs and filenames -- **No padding**: Removes trailing `=` characters for cleaner output -- **String output**: Returns proper strings instead of bytes (unlike Python's standard library) +- **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 @@ -17,7 +17,7 @@ Replaces the standard library's `base64.urlsafe_b64encode` and `base64.urlsafe_b pip install base64url ``` -Or for your project using [uv](https://docs.astral.sh/uv/): +Or for your project using [UV](https://docs.astral.sh/uv/getting-started/installation/): ```sh uv add base64url ``` @@ -33,16 +33,16 @@ data = base64url.dec(text) # Recovers the bytes ### `enc(data: bytes) -> str` -Base64 encode bytes to a URL-safe string without padding. +Encode bytes to a urlsafe string without padding. ### `dec(s: str, *, validate=True) -> bytes` -Decode URL-safe Base64 into bytes. Padding optional. Set `validate=False` to silently ignore any unknown characters (Python base64 default behavior). +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: int = 76) -> str` +### `enc_lines(data: bytes, length=76, sep="\n") -> str` -Encode with newlines inserted every `length` characters. +Encode with newlines inserted every length characters. Does not add a newline at the end. ### `dec_lines(s: str) -> bytes` -Decode formatted input, ignoring all whitespace (but not other unknown characters). +Decode formatted input, ignoring whitespace. Raises binascii.Error on invalid characters. diff --git a/pyproject.toml b/pyproject.toml index d8b8071..3f41314 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "base64url" -version = "1.1.0" +version = "1.1.1" description = "Base64 encoding without Python's base64 flaws. Output urlsafe without padding, as str. Decodes any variant with or without padding, with validation." readme = "README.md" requires-python = ">=3.8"