Hexoid ID Generator

2.0.0 · active · verified Sun Apr 19

Hexoid is a minimalist (190B) and high-performance utility designed for generating fixed-length, randomized hexadecimal IDs in JavaScript environments, including Node.js and browsers. The current stable version is 2.0.0, which introduced significant changes for improved module interoperability. It is primarily used when a quick, unique string identifier is needed, but cryptographic security is not a requirement. Key differentiators include its extreme speed, small footprint, and focus on simple hexadecimal output, contrasting with larger, more feature-rich UUID libraries. While it provides good collision resistance for common use cases, users must be aware it is not cryptographically secure and the risk of collisions increases with shorter lengths, as detailed by the Birthday Problem.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `hexoid` function and generate IDs with default and custom lengths.

import { hexoid } from 'hexoid';

// Create a generator for default length (16 characters)
const generateDefaultId = hexoid();
console.log('Default ID:', generateDefaultId());
// Example output: '52032fedb951da00'

// Create a generator for a custom length (e.g., 25 characters)
const generateCustomId = hexoid(25);
console.log('Custom length ID:', generateCustomId());
// Example output: '065359875047c63a037200e00'

// Create multiple IDs from the same generator
const toID = hexoid();
console.log('ID 1:', toID());
console.log('ID 2:', toID());
console.log('ID 3:', toID());

view raw JSON →