mohd-akram / simple-id

A Node.js library for generating short, user-friendly, random IDs.

Home Page:https://www.npmjs.com/package/simple-id

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple-id

A library for generating short, user-friendly, random IDs.

Install

npm install simple-id

Usage

const simpleId = require("simple-id");
simpleId();

By default, an 8-character random ID is generated using a 31-character alphabet (23456789abcdefghjkmnpqrstuvwxyz) which notably excludes the uppercase letters and 01ilo to avoid ambiguity. This gives about 853 billion possible permutations. A different length and/or alphabet can be passed as follows:

simpleId(9);
simpleId(8, "0123456789abcdef");

Implementation

The implementation uses Node's cryptographically strong crypto.randomBytes() function and provides uniformly distributed random IDs. It has no other dependencies.

About

A Node.js library for generating short, user-friendly, random IDs.

https://www.npmjs.com/package/simple-id

License:MIT License


Languages

Language:JavaScript 100.0%