nanoid (Nano ID, a UUID alternative - machine-ported from Javascript)
DanielG
simpletangent at gmail.com
Wed Nov 25 15:17:22 UTC 2026
git: https://github.com/dewf/nanoid-dlang
Dub: https://code.dlang.org/packages/nanoid
from the README:
>A tiny, secure, URL-friendly, unique string ID generator for the
>D programming language.
>
>This library is a native, D-idiomatic port of the original
>JavaScript [Nano ID](https://github.com/ai/nanoid) library by
>Andrey Sitnik.
>
>- **Zero dependencies.** Uses only Phobos, druntime, and native
>OS cryptographic APIs.
>- **Cryptographically secure.** Uses the operating system's
>CSPRNG with a lock-free, fork-safe thread-local entropy pool.
>- **Unbiased distribution.** Uses bitmask and cutoff rejection
>sampling instead of naive modulo indexing, avoiding modulo bias
>across all alphabet sizes.
>- **Compact & URL-safe.** Uses a 64-symbol alphabet
>(`A-Za-z0-9_-`), packing 126 bits of entropy into 21 characters
>(comparable to UUID v4's 122 bits in 36 characters).
>- **Idiomatic D.** `@safe`, `-preview=dip1000`-compatible,
>CTFE-capable `customAlphabet`, full UTF-8/Unicode alphabet
>support, and `@nogc nothrow` in-place buffer primitives.
More information about the Digitalmars-d-announce
mailing list