Stripe-like tokens in pure-python with no dependencies.
Project description
Heare IDs
A Python module for creating, validating, parsing, and manipulating tokens that are base-62 encoded.
Features
- Generate unique tokens with a prefix, generation character, timestamp, and entropy part
- Validate the structure and character set of tokens
- Parse tokens into their components (prefix, generation, timestamp, entropy)
- Swap the prefix of a token with a new prefix
Installation
pip install heare-ids
Usage
Generating Tokens
from heare import ids
# Generate a new token with default settings
token = ids.new('my_prefix')
# Generate a token with custom generation, timestamp, and entropy
token = ids.new('my_prefix', generation='A', timestamp=1234567890, entropy=15)
Validating Tokens
is_valid = ids.is_valid(token)
Parsing Tokens
parsed = ids.parse(token)
prefix = parsed.prefix
generation = parsed.generation
timestamp = parsed.timestamp
entropy = parsed.entropy
Swapping Prefixes
new_token = ids.swap_prefix(token, 'new_prefix')
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
heare_ids-0.1.0.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file heare_ids-0.1.0.tar.gz
.
File metadata
- Download URL: heare_ids-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b96c177ff23dce9bf1db0debdf9476abaded5faad9bebe11698be01fb8f77fe |
|
MD5 | 2e2c3afcedafa8be8ef5cc62a2896546 |
|
BLAKE2b-256 | bde1bc8e5636bda2052cd37c30ba5d5ab0b389acd9b628cfc38cc108e88d355f |
File details
Details for the file heare_ids-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: heare_ids-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 641c26cbcc51bb1cc4534ecc40059c8c09d818344d5de21d182dd701f540e2a3 |
|
MD5 | d4bf71b43cab97b19d94c12b067354cc |
|
BLAKE2b-256 | 3779e8f48bad5c2865d72e13432f403eb0a943a4304b3fec65e10a86650f8eec |