Skip to main content

A library for creating self-aware ids

Project description


A library for creating self-aware ids.


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

import nuggan

# user-44cc2faf-b1a4-47ad-a1fe-4bc81dfd965a-4a6e8fc57d86

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

my_id = 'user-44cc2faf-b1a4-47ad-a1fe-4bc81dfd965a-4a6e8fc57d86'
# {
#     'prefix': 'user',
#     'prefixed_id': 'user-44cc2faf-b1a4-47ad-a1fe-4bc81dfd965a',
#     'base_id': '44cc2faf-b1a4-47ad-a1fe-4bc81dfd965a',
#     'checksum': '4a6e8fc57d86'
# }

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

corrupted_id = 'user-44cc2faf-look-this-aint-rightdfd965a-4a6e8fc57d86'
# 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-99a528df-ff28-435d-8fc6-1c1f51aaa7c2-5b70075ae688
normal_id = nuggan.create_id('user')
# user-ffe386b7-689c-4ab7-95b4-304fa83a64a0-35d605d62ffa

# True
# False

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

nuggan-0.1.1.tar.gz (3.6 kB view hashes)

Uploaded source

Built Distribution

nuggan-0.1.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page