Short UID Generator
Short, URL-safe unique identifier generator.
Overview
VCollab applications frequently need short, unique identifiers for temporary file names, directory names, session IDs, or other scenarios where brief, collision-resistant strings are needed.
The vcti-short-uid package provides ShortUID — a generator that
produces a random identifier of an exact length from the URL-safe base64
alphabet [A-Za-z0-9_-], backed by secrets.token_urlsafe.
This package has zero external dependencies.
When to use it
ShortUID gives you a short, URL-safe identifier of an exact length in a
single call — handy for temporary file and directory names, cache keys,
or session tags. It is not a secrets generator: outputs are short and,
at small lengths, guessable. For unguessable tokens use
secrets.token_urlsafe() directly, and for a standard 128-bit identifier
use uuid.uuid4(). See the
full comparison.
Installation
pip install vcti-short-uid
In requirements.txt
vcti-short-uid>=2.0.0
In pyproject.toml dependencies
dependencies = [
"vcti-short-uid>=2.0.0",
]
Quick Start
from vcti.shortuid import ShortUID
# One-shot generation (no instance needed)
uid = ShortUID.quick() # e.g. "a3Bx9kLm"
# Custom length
long_uid = ShortUID.quick(length=16) # 16-char ID
# Reusable generator
gen = ShortUID(length=8)
uid1 = gen.generate()
uid2 = gen.generate()
Public API
ShortUID(length=8)
Create a generator instance.
| Parameter | Type | Default | Description |
|---|---|---|---|
length |
int |
8 |
Exact number of characters in generated IDs (minimum 1, no upper cap) |
Raises:
TypeError-- iflengthis not an integer.ValueError-- iflengthis less than 1.
ShortUID.generate() -> str
Generate a short, URL-safe identifier of exactly length characters,
drawn from [A-Za-z0-9_-].
ShortUID.quick(length=8) -> str (classmethod)
Convenience one-liner -- creates a temporary instance and generates one ID.
repr(ShortUID(...))
Returns a string like ShortUID(length=8) for debugging.
Dependencies
None. Standard library only (math, secrets).
Documentation
| If you want to… | Read |
|---|---|
| Get started using the package | Quick Start above |
| Understand the architecture and design decisions | docs/design.md |
| Navigate and understand the source | docs/source-guide.md |
| Look up a specific function or type | docs/api.md |
| See the release history | CHANGELOG.md |
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vcti_short_uid-2.0.0.tar.gz.
File metadata
- Download URL: vcti_short_uid-2.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03852950fd3e8fa793ec60a4741c96cab9fc4ecc25719f40635365a07d45d6ad
|
|
| MD5 |
4499cdf8c7af57de3e51ce091f3705db
|
|
| BLAKE2b-256 |
b22cb9d98ec10b5d2b8c154b66528e01ee4f653e6bfd43f9f96b863c95fb0700
|
Provenance
The following attestation bundles were made for vcti_short_uid-2.0.0.tar.gz:
Publisher:
release.yml on vcollab/vcti-python-short-uid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_short_uid-2.0.0.tar.gz -
Subject digest:
03852950fd3e8fa793ec60a4741c96cab9fc4ecc25719f40635365a07d45d6ad - Sigstore transparency entry: 2233375193
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-short-uid@c56263867902c42a91f5d664774b67f86c3d1619 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c56263867902c42a91f5d664774b67f86c3d1619 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vcti_short_uid-2.0.0-py3-none-any.whl.
File metadata
- Download URL: vcti_short_uid-2.0.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
065560e68480634c8f57315d197eac6d6d554997843709600079f6b1eee1840c
|
|
| MD5 |
217ebbbd09385032c773c175d7cc4a7a
|
|
| BLAKE2b-256 |
43719d4e44ae1c8ca976e0ee40d20a3031decce6d988bcfc25fdb902d47271c1
|
Provenance
The following attestation bundles were made for vcti_short_uid-2.0.0-py3-none-any.whl:
Publisher:
release.yml on vcollab/vcti-python-short-uid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_short_uid-2.0.0-py3-none-any.whl -
Subject digest:
065560e68480634c8f57315d197eac6d6d554997843709600079f6b1eee1840c - Sigstore transparency entry: 2233375959
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-short-uid@c56263867902c42a91f5d664774b67f86c3d1619 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c56263867902c42a91f5d664774b67f86c3d1619 -
Trigger Event:
push
-
Statement type: