Skip to main content

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


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.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

heare_ids-0.1.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file heare_ids-0.1.3.tar.gz.

File metadata

  • Download URL: heare_ids-0.1.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for heare_ids-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5067a9405dc851b6b46a5403a98b3c86bace751924d4a49d3e2788b045e1dfa9
MD5 6251dc843046ea8013fca22f7ca3dcbe
BLAKE2b-256 82defe84da6a536be7bc5999ae15aaebbc86b9dd837472754daa8ec7244343f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for heare_ids-0.1.3.tar.gz:

Publisher: publish-to-pypi.yml on heare-io/heare-ids

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file heare_ids-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: heare_ids-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for heare_ids-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5d50d6b04115ee1f9b69cbe1b326460a8ef3a247fb0bc12f8c78aaacd739d1dc
MD5 01b86f92b7849f55523c3c92c12436fe
BLAKE2b-256 67892f47b7470b3fea8bde8f9c60d57c49b55eb0672e0705234cd1702235f2c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for heare_ids-0.1.3-py3-none-any.whl:

Publisher: publish-to-pypi.yml on heare-io/heare-ids

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page