v1.1.1 - README cleanup.
This commit is contained in:
@@ -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.
|
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
|
## Features
|
||||||
|
|
||||||
- **Urlsafe**: Uses only characters that are safe for URLs and filenames
|
- **Urlsafe**: Uses only characters that are safe for URLs and filenames
|
||||||
- **No padding**: Removes trailing `=` characters for cleaner output
|
- **No padding**: Removes trailing `=` characters for a cleaner, actually urlsafe output
|
||||||
- **String output**: Returns proper strings instead of bytes (unlike Python's standard library)
|
- **String output**: Returns Base64 as str instead of bytes
|
||||||
- **Fast**: Based on Python stdlib, with constant-time padding restoration
|
- **Fast**: Based on Python stdlib, with constant-time padding restoration
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -17,7 +17,7 @@ Replaces the standard library's `base64.urlsafe_b64encode` and `base64.urlsafe_b
|
|||||||
pip install base64url
|
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
|
```sh
|
||||||
uv add base64url
|
uv add base64url
|
||||||
```
|
```
|
||||||
@@ -33,16 +33,16 @@ data = base64url.dec(text) # Recovers the bytes
|
|||||||
|
|
||||||
### `enc(data: bytes) -> str`
|
### `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`
|
### `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`
|
### `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.
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "base64url"
|
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."
|
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"
|
readme = "README.md"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
|
|||||||
Reference in New Issue
Block a user