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.2.tar.gz (3.7 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.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: heare_ids-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 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.2.tar.gz
Algorithm Hash digest
SHA256 9707f2373d7904005a7295921ab8f93b4409c05ee29900ebb09636248e9a7784
MD5 2cc007827f0d054002c615d09518e732
BLAKE2b-256 7003e04f1eaf0e5d3c51446d697b7de9b2b929b4bdc17dd3b1b0dc3dc70e193e

See more details on using hashes here.

Provenance

The following attestation bundles were made for heare_ids-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: heare_ids-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bdb49937a5aaaf4bf9cbab00075d6dfa9bcfb212999a820475d7a12e0ea3434a
MD5 f11c37dfb8f104334e20ce2d25aca95e
BLAKE2b-256 92b433048a473684c5e0aa598121318b02b1356c2da2a1af42576b4c4d253312

See more details on using hashes here.

Provenance

The following attestation bundles were made for heare_ids-0.1.2-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