Skip to main content

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 -- if length is not an integer.
  • ValueError -- if length is 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

Metadata

Release files for vcti-short-uid 2.0.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 vcti-short-uid 2.0.0
File Size Uploaded Provenance Actions
vcti_short_uid-2.0.0.tar.gz 6.2 kB With provenance Details for vcti_short_uid-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vcti-short-uid 2.0.0
File Interpreter ABI Platform Actions
vcti_short_uid-2.0.0-py3-none-any.whl Python 3 none any Details for vcti_short_uid-2.0.0-py3-none-any.whl

Total release size: 11.3 kB

Release files / vcti_short_uid-2.0.0.tar.gz

Download URL vcti_short_uid-2.0.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
03852950fd3e8fa793ec60a4741c96cab9fc4ecc25719f40635365a07d45d6ad
BLAKE2b-256 checksum
How to use checksums
b22cb9d98ec10b5d2b8c154b66528e01ee4f653e6bfd43f9f96b863c95fb0700
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Release files / vcti_short_uid-2.0.0-py3-none-any.whl

Download URL vcti_short_uid-2.0.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
065560e68480634c8f57315d197eac6d6d554997843709600079f6b1eee1840c
BLAKE2b-256 checksum
How to use checksums
43719d4e44ae1c8ca976e0ee40d20a3031decce6d988bcfc25fdb902d47271c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

Security for vcti-short-uid 2.0.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vcti_short_uid-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.

Transparency log

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