A Python module for creating, validating, parsing, and manipulating tokens that are base-62 encoded.
- 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
pip install heare-ids
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)
is_valid = ids.is_valid(token)
parsed = ids.parse(token)
prefix = parsed.prefix
generation = parsed.generation
timestamp = parsed.timestamp
entropy = parsed.entropy
new_token = ids.swap_prefix(token, 'new_prefix')
This project is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request.