vercel / uid-promise

Creates a cryptographically strong UID

Home Page:https://npmjs.com/uid-promise

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

uid-promise

Creates a cryptographically secure UID with a 62 character range that can be safely used in URLs.

Usage

Install the package:

npm i uid-promise

Then import it:

import { uid } = from 'uid-promise';

Finally, call it:

await uid(20);

API

uid(Number len) => Promise

  • Return a Promise that resolves with a string of random characters of length len
  • len must always be provided, else the promise is rejected
  • Under the hood, crypto.randomBytes is used
  • Character set: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789

Authors

About

Creates a cryptographically strong UID

https://npmjs.com/uid-promise

License:MIT License


Languages

Language:TypeScript 53.7%Language:JavaScript 46.3%