ouidNew()
The ouidNew()
function generates a unique identifier string suitable for use as database keys, session IDs, or any other scenario requiring unique values.
Syntax
Parameters
This function doesn't take any parameters.
Return Value
Returns a string containing a cryptographically strong unique identifier.
Description
The ouidNew()
function creates unique identifiers by combining several sources of entropy including:
Current timestamp
System performance metrics
User's unique identifier
The result is then hashed using SHA-256 to create a fixed-length unique string that's suitable for:
Database record identifiers
Session or authentication tokens
Unique filenames
Entity tracking in applications
Temporary identifiers for objects
Examples
Basic Usage
Creating Unique Database Records
Generating Unique Filenames
Creating Temporary Tokens
Notes
The generated IDs are cryptographically strong and suitable for most applications
The function generates a different ID on every call
The length and format of the ID is consistent across all calls
For extremely high-volume systems with thousands of IDs per second, consider monitoring for potential collisions
The function generates strings that are suitable for use in URLs and filenames
Last updated
Was this helpful?