uuid_shortener
uuid_shortener is a library for shortening UUIDs into an alphanumerical format suitable for usage in URLs.
The alphanumerical format is Flicker base 58 encoding.
Installation
from Pypi:
pip install uuid-shortener-py
Module usage
The UuidShortener object can be created with/without a prefix.
Example 1: without prefix
from uuid_shortener import UuidShortener
from uuid import uuid4
if __name__ == "__main__":
print('******** Without prefix')
shortener = UuidShortener()
uuid_4 = uuid4()
short_uuid = shortener.shorten(uuid_4)
unshortened_uuid = shortener.unshorten(short_uuid)
print(f'Uuid to shorten: {uuid_4}')
print(f'shortened uuid: {short_uuid}')
print(f'unshortened uuid(original uuid): {shortener.unshorten(short_uuid)}')
Output 1:
******** Without prefix
Uuid to shorten: 177d1b53-77d5-42b2-8b8f-8d86579deb52
shortened uuid: 3Ueemi554rN46ioLFw3dZG
unshortened uuid(original uuid): 177d1b53-77d5-42b2-8b8f-8d86579deb52
Example 2: with prefix
from uuid_shortener import UuidShortener
from uuid import uuid4
if __name__ == "__main__":
print('******** With prefix')
shortener = UuidShortener('meow')
uuid_4 = uuid4()
short_uuid = shortener.shorten(uuid_4)
unshortened_uuid = shortener.unshorten(short_uuid)
print(f'Uuid to shorten: {uuid_4}')
print(f'shortened uuid: {short_uuid}')
print(f'unshortened uuid (original uuid): {shortener.unshorten(short_uuid)}')
Output 2:
******** With prefix
Uuid to shorten: 2bea23d4-2b96-485d-8788-0c606ab93319
shortened uuid: meow-6qwbaCZnHtxJsj4uJTKJSV
unshortened uuid (original uuid): 2bea23d4-2b96-485d-8788-0c606ab93319
As an easy, one-way generator
from uuid_shortener import ShortUuidGenerator
from uuid import uuid4
if __name__ == "__main__":
print('******** Generator')
uuid_gen = ShortUuidGenerator(prefix='meow', uuid=uuid4)
print('Shortened uuid 1: {}'.format( uuid_gen() ))
print('Shortened uuid 2: {}'.format( uuid_gen() ))
Output 3:
******** Generator
Shortened uuid 1: meow-9ubC52uXU1MM9PcrUMaNNc
Shortened uuid 2: meow-wqTnxvHfWzrPvREcVi5RAf
License
Metadata
Release files for uuid-shortener-py 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uuid-shortener-py-1.1.0.tar.gz | 4.0 kB | Without provenance | Details for uuid-shortener-py-1.1.0.tar.gz |
Release files / uuid-shortener-py-1.1.0.tar.gz
| Download URL | uuid-shortener-py-1.1.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
561edcd3caafc82c2d1590f0ea6914bde3ee4eaa40d374e829cc1f465be0b8c9
|
|
BLAKE2b-256 checksum How to use checksums |
9b13680123e8bd1fa878d5cfe37fd5ccb9f78de28392d96188076e53bc75ff33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.3
|
Security for uuid-shortener-py 1.1.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.