CUID (Collision-resistant Unique IDentifier)

0.4 · deprecated · verified Sun Apr 12

cuid.py is a Python implementation of the original CUID (Collision-resistant Unique IDentifier) standard, designed for horizontally scalable and fast unique ID generation. It aims to provide portable and sequentially-ordered unique identifiers. The current version is 0.4. The upstream CUID standard (v1), which this library implements, has been deprecated in favor of CUID2 due to security considerations, so this library is not actively developed beyond maintenance for the deprecated standard.

Warnings

Install

Imports

Quickstart

Demonstrates how to generate a standard CUID and a shorter CUID slug using the library. Note the warning about slugs for primary keys.

import cuid

# Generate a standard CUID
my_cuid = cuid.cuid()
print(f"Generated CUID: {my_cuid}")

# Generate a 'slug' (shorter, less collision-resistant, not for primary keys)
my_slug = cuid.slug()
print(f"Generated CUID slug: {my_slug}")

view raw JSON →