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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcti_short_uid-2.0.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcti_short_uid-2.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

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

Hashes for vcti_short_uid-2.0.0.tar.gz
Algorithm Hash digest
SHA256 03852950fd3e8fa793ec60a4741c96cab9fc4ecc25719f40635365a07d45d6ad
MD5 4499cdf8c7af57de3e51ce091f3705db
BLAKE2b-256 b22cb9d98ec10b5d2b8c154b66528e01ee4f653e6bfd43f9f96b863c95fb0700

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for vcti_short_uid-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 065560e68480634c8f57315d197eac6d6d554997843709600079f6b1eee1840c
MD5 217ebbbd09385032c773c175d7cc4a7a
BLAKE2b-256 43719d4e44ae1c8ca976e0ee40d20a3031decce6d988bcfc25fdb902d47271c1

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.3.0

2 files

1.2.1

2 files

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