Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mohd-akram/simple-id
A Node.js library for generating short, user-friendly, random IDs.
https://github.com/mohd-akram/simple-id
id node nodejs npm random
Last synced: 25 days ago
JSON representation
A Node.js library for generating short, user-friendly, random IDs.
- Host: GitHub
- URL: https://github.com/mohd-akram/simple-id
- Owner: mohd-akram
- License: mit
- Created: 2017-07-02T13:51:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-25T08:41:31.000Z (5 months ago)
- Last Synced: 2024-09-29T05:52:47.427Z (about 1 month ago)
- Topics: id, node, nodejs, npm, random
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/simple-id
- Size: 15.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-id
A library for generating short, user-friendly, random IDs.
## Install
npm install simple-id
## Usage
```javascript
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:```javascript
simpleId(9);
simpleId(8, "0123456789abcdef");
```## Implementation
The implementation uses the cryptographically strong `crypto.getRandomValues()`
function and provides uniformly distributed random IDs. It has no other
dependencies.