Skip to main content

Nuggan

A library for creating informed ids. Nuggan ids aim to provide the following properties.

  • The id knows the type of entity it is identifying.
  • The authenticity of an id can be established just by looking at the id value. That is to say that a nuggan user can determine whether an id given to them is one they previously generated.
  • The alphabetical ordering of a list of ids is relatively equivalent to their chronological ordering.

Usage

Use nuggan to generate ids that encode information about the entity being identified.

import nuggan

nuggan.create_id('user')
# user-005dd1c485-7367ea24-e668-4944-9de0-723112eb1089-e8d26af99684

When given an id it can be parsed to identify what it applies to.

my_id = 'user-005dd1c485-7367ea24-e668-4944-9de0-723112eb1089-e8d26af99684'
nuggan.parse_id(my_id)
# {
#   'prefix': 'user',
#   'hex_time': '005dd1c485',
#   'prefixed_id': 'user-005dd1c485-7367ea24-e668-4944-9de0-723112eb1089',
#   'base_id': '7367ea24-e668-4944-9de0-723112eb1089',
#   'checksum': 'e8d26af99684'
# }

Ids have checksums associated with them to allow corrupted ids to be identified.

bad_id = 'user-005dd1c485-44cc2faf-look-this-aint-rightdfd965a-4a6e8fc57d86'
nuggan.is_valid_id(bad_id)
# False

A salt can be configured to give some amount of confidence that a given id originated from a specific source.

maker = nuggan.IdMaker(salt='an-arbitrary-salt-value')
salted_id = maker.create_id('user')
# user-005dd1c5b4-e4d94f47-cae0-4f16-a0d8-a953c9bd7209-d93cd221c394
normal_id = nuggan.create_id('user')
# user-005dd1c5d8-fd007e41-833f-4c00-8aa9-a26314142845-895de953856b

maker.is_valid_id(salted_id)
# True
maker.is_valid_id(normal_id)
# False

Metadata

Release files for nuggan 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nuggan 0.2.0
File Size Uploaded Provenance Actions
nuggan-0.2.0.tar.gz 4.0 kB Without provenance Details for nuggan-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nuggan 0.2.0
File Interpreter ABI Platform Actions
nuggan-0.2.0-py3-none-any.whl Python 3 none any Details for nuggan-0.2.0-py3-none-any.whl

Total release size: 8.2 kB

Release files / nuggan-0.2.0.tar.gz

Download URL nuggan-0.2.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
84fbef53a2037c3d7edd88d4ef38f82c5543e8a6d5fc81ef72ad5b7e77100e85
BLAKE2b-256 checksum
How to use checksums
c2c7ee711e7245d766359f9491bab59ed5830d000c9d837e1336e8eea3d26461
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.2 Linux/4.15.0-70-generic

Release files / nuggan-0.2.0-py3-none-any.whl

Download URL nuggan-0.2.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b2a96e679378f741e933603dbdb3ecc1ac7e6a8e0d4c66d24f803f3d8c2f339
BLAKE2b-256 checksum
How to use checksums
38120bdc3825e2b0ce800e65371b6c584841cbf5ec66651d7a908e59bb2d7db6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.2 Linux/4.15.0-70-generic

Security for nuggan 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page