@gaurav-udawant/unique-id
v1.0.1
Published
Universal cryptographically secure random ID generator
Maintainers
Readme
🆔 @gaurav-udawant/unique-id
A lightweight, zero-dependency utility to generate cryptographically secure 64-character universal random IDs.
✨ Features
🔐 Cryptographically Secure Uses
globalThis.crypto.getRandomValues()to generate high-entropy random IDs.🌍 Universal Compatibility Works in Node.js as well as modern web browsers.
📦 Zero Dependencies No external libraries — keeps your project fast and lightweight.
🟦 TypeScript Ready Built with TypeScript, providing type safety and autocomplete out of the box.
📦 Installation
Install using npm, yarn, or pnpm.
npm install @gaurav-udawant/unique-idor
yarn add @gaurav-udawant/unique-idor
pnpm add @gaurav-udawant/unique-id🚀 Usage
ESM / TypeScript
Import the generateUniversalRandomId function and generate a secure random ID.
import { generateUniversalRandomId } from '@gaurav-udawant/unique-id';
const randomId = generateUniversalRandomId();
console.log(randomId);
// Example Output:
// a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f90CommonJS
const { generateUniversalRandomId } = require('@gaurav-udawant/unique-id');
const randomId = generateUniversalRandomId();
console.log(randomId);⚙️ How It Works
- Creates a 32-byte
Uint8Array. - Fills it with cryptographically secure random values using the Web Crypto API.
- Converts those bytes into a continuous hexadecimal string.
Result → A 64-character secure random ID suitable for universal use.
👨💻 Author
Gaurav Udawant
🔗 GitHub https://github.com/gaurav23feb
📄 License
MIT License
