ID & Random Utilities
Documentation for unique identifiers, UUIDs, short IDs, OTPs, and random number generators in sc-fns/id.
The sc-fns/id module provides cryptographically secure identifier generators and random value helpers.
ts
generateUUID
Generates an RFC 4122 version 4 UUID string. Uses native crypto.randomUUID() in modern runtimes, with a secure fallback for environments lacking direct support.
Signature
ts
Examples
ts
generateShortId
Generates a compact, URL-safe random identifier. Useful for database primary keys, URL shorteners, or temporary session tags.
Signature
ts
Examples
ts
generateOTP
Generates a numeric One-Time Password (OTP) of specified length. Uses cryptographically secure random values when available.
Signature
ts
Examples
ts
randomNumber
Generates a pseudo-random number within an inclusive [min, max] range.
Signature
ts
Examples
ts
randomBoolean
Returns a boolean value with an optional probability weighting.
Signature
ts
Examples
ts
randomHex
Generates a random hexadecimal string of the specified byte length.
Signature
ts
Examples
ts
How is this guide?
Last updated on October 25, 2026