Cuid2
Next generation GUIDs. Collision-resistant ids optimized for horizontal scaling and performance.
Install / Use
/learn @gordon-code/Cuid2README
cuid2
CUID2 for Python 3. Next generation GUIDs. Collision-resistant ids optimized for horizontal scaling and performance.
A port of the CUID2 reference implementation by Parallel Drive to Python 3.
:memo: Note: Originally taken from https://github.com/overflowdigital before it was unpublished. Thank you to @joshuathompsonlindley for your original contribution!
What is CUID2?
- Secure: It's not possible to guess the next ID.
- Collision resistant: It's extremely unlikely to generate the same ID twice.
- Horizontally scalable: Generate IDs on multiple machines without coordination.
- Offline-compatible: Generate IDs without a network connection.
- URL and name-friendly: No special characters.
Why?
For more information on the theory and usage of CUID2, see the following.
Improvements Over CUID
For more information on the improvements of CUID2 over CUID, see the following.
Install
pip install cuid2
Usage
You can generate CUIDs directly in the terminal with the following:
$ cuid2
Or you can rely on a CUID wrapper if you don't need any customizations:
from typing import Callable
from cuid2 import cuid_wrapper
cuid_generator: Callable[[], str] = cuid_wrapper()
def main():
my_cuid: str = cuid_generator()
next_cuid: str = cuid_generator()
Finally, for more explicit control of the CUID generator, you can instantiate the class directly:
from cuid2 import Cuid
CUID_GENERATOR: Cuid = Cuid(length=10)
def main():
my_cuid: str = CUID_GENERATOR.generate()
next_cuid: str = CUID_GENERATOR.generate()
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
